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

No comments:

Post a Comment

Feel free to leave a comment about this tutorial below.
Any questions about your particular project should be asked in the ArduinoBasics forum.

Comments are moderated due to large amount of spam.