Arduino Basics: Colour
Showing posts with label Colour. Show all posts
Showing posts with label Colour. Show all posts

19 August 2011

Poor Man's Colour Detector (Part 2) - The project

In this project we will be detecting the colour of 3 different Mega Blok colours (Red, Yellow and Green). We will be using an Arduino UNO connected to  2 LEDs (one Yellow and one Red LED) as light detectors, and an RGB LED to illuminate the subject. We will use a Photocell to account for varying ambient light levels. 

The signals from the LED light sensors will be sent to a Processing.org program via a Serial command. The computer program will make use of my Neural Network to classify the pattern of results and hopefully provide the correct colour "answer". The program should change the colour of the computer screen background to coincide with the colour of the Mega Blok.

The Video


4 August 2011

Poor Man's Colour Detector (Part 1) - The concept

Well, I have finally done it. Not sure if I should post the tutorial, because it is not very basic. But then again, a novice like me managed to do it, so why not !! We will need to pull together a number of previous blogs, but rather than jumping back and forth, I think I will just walk you through from beginning to end, and hope that I don't lose you along the way. 

The concept

In my earlier blog posts, I managed to get LEDs to detect light. And through a bit of trial an error, plus a bit of internet research, I found out that an LED will detect light of the same wavelength that it emits. Therefore a red LED will detect RED light, and a yellow LED will detect yellow light etc etc.

I decided to test this theory by placing different coloured MEGA-BLOKs over the LEDs to see if there was any difference ? And from my simplistic experiments, I could see that the RED LED responded much better to a RED Mega-blok than any other colour, and a YELLOW LED responded much better to a Yellow mega-blok than any other colour.

I decided to test out another theory.
Could I detect other mega-blok colours using a red and yellow LED?

While I was aware that I would be better off using primary colour LEDs (RYB - red yellow and blue) or even RGB (red green and blue) in this experiment, I was limited by the LEDs that came in the Sparkfun's Inventor Kit. So I had to use red and yellow.

I developed a little program in "Processing" that would change the colour of the computer screen based on the colour of the mega-blok sitting over the LEDs. I would use specific cut-off values to separate the different readings and translate them into 4 different classes. This was a bit hit and miss. Depending on the ambient light level, the cut-off values would shift. Plus there was a bit of imprecision in the readings.

I then decided to introduce an RGB LED to shine light on the subject. This helped a bit, however, changes in ambient light were proving to be my enemy. I then introduced a photo-cell, however, by this stage, I had so many values and readings and conditions to meet, that I almost gave up.

That was until I read something about neural networks. Then the real fun began. One month later, and a determined novice that was keen to see this project through to the end, my Arduino UNO can now detect coloured mega-bloks!! How did I do it?  I made the computer figure it out !!

Using a feed-forward neural network with a supervised learning back-propagation model (don't switch off just yet), I got the computer to learn the colours under different light conditions and voila ! I ended up with an Arduino UNO and a couple of LEDs (and photocell) that could tell me what colour Mega-blok was sitting over it. The end result is not 100% perfect, but it works quite well.

In the next part, I will walk you through my neural network step by step. Not sure how this tutorial will pan out, but I'll do my best. (Click here for the Neural Network Tutorial)

Or go here for the table of contents

19 June 2011

Colour Sensing - Update Two

This colour sensing project is starting to get bigger than I wanted it to. However, I am learning a lot about the Arduino/Processing as I look for ways to accomplish my tasks. When you see my final code, I will have a bit of explaining to do.

I now have a relatively quick method of detecting MegaBlok colours, and will probably use a PhotoCell to improve read rates under different lighting conditions. Once I have done this, I would like to get the Arduino to do something in response to the colour. But let me get over step one.

12 June 2011

Colour Sensing - Update One

I successfully modified the previous sketch to detect the colour of the Mega Blok that was over the sensors. However, it was taking up to 10-20 seconds to reveal the answer.

The problem I am experiencing is mainly due to the effect of ambient light levels. Just when I get all my limits set up, something changes, and I lose the ability to identify one of the Bloks.

I get the feeling that I may have over-complicated the design or the method to detect the Blok colour, and am now trying to simplify and speed up the process.

Once again, I think I may be able to get faster results using a PhotoCell, but I don't want to differentiate by light level alone. I would like to read colour using one or more LEDs as a Sensor.

I think I need to utilise the RGB LED functionality a little bit more. So instead of white light, I might scan with different colours.

Stay tuned.

If you have any ideas, please make suggestions in the comments.

Colour Sensing - Intro

Now that I have different patterns for the different coloured Mega Bloks, I will try to get processing to "Identify" or tell me which Blok is which. I am essentially trying to make a DIY colour sensor.
I know that if I get the RGB LED to produce different coloured light (rather than just white), I will be able to get more information/patterns from my Red and Yellow LED sensors, however, I think I have enough information from the white light to tell the difference between the Red, the yellow and the green Mega Bloks.

We'll see how we go. Stay tuned.

For more information about what project I referring to - jump to this Blog Posting:
Arduino UNO: LED Sensor Part Two