Let's Make Robots!

Color Sensor Algorithm

color%20sensor.JPG

I know the video quality sucks I just wanted to give a view of  what it is doing. The black tube has the LDR in it to hide stray light. Below is a tabl eof the values I got for Red, Blue and Green when different color soda caps were put in front of the LDR. Now I need to take the raw values and put them into some sort of algorithm that looks at the difference between the values before a cap is put in place and after to determine the cap color.

 

 

LED Color                            
red LED 68 88 93 142 126 188 126 157 77 62 55 182 146 130
blue LED 67 83 106 118 101 125 89 134 111 83 74 184 150 112
green LED 68 117 122 115 98 153 90 119 94 57 64 190 150 122
Cap Color ambient light green dark green red dark red yellow orange pink blue dark blue dark teal white clear gold

 

cap%20color%20chart.JPG

 

I swapped out the 10k resistor on the LDR to a 1k I think it made the values way too low as blue and green always stay fairly low. However red is very high. I think I need to change the 1k resistor to a 5k and take the resistor on the red LED and swap it for a higher one to make the light less intense. More to come!

 Update 6/8/09:

Not much to update but I replaced all of the resistors with pots to try to dial in the appropriate resistor values. Its funny how wacky the behavior gets. At one point when the blue LED came on I could see the reflection on the LDR, but yet the values dropped. CRAZY! 

Update 6/8/09:

Got values from the pots transferred to resistors and I am getting fairly consistent values. Now to make an algorithm that takes ambient light then the values with the cap in place and determines the color. More to come tomorrow hopefully...

 

Update 6/17/09

Got some 100ohm, 500ohm and 2kohm pots to better dial in the resistance values. I also updated the chart with the values I get with each color. Next is to solder the sensor to perf board with the resistor values of:  2.83k for the LDR, 448ohm for the red LED, 8ohm for the blue LED, and 66ohm for the green LED.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I just skimmed over the wikipedia on that distance thingey. Woosh! Over my head. And I suspect over Picaxe's head as well. But I agree that this algorithm is exactly what is required to solve this colour matching game.

Mahalanobis Picaxe library writers, report on this node!

Here's aq good write up i=on making your own color sensor.

 http://www.robotroom.com/ColorSensor.html