Color Sensor Algorithm
June 5, 2009
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.
|Cap Color||ambient||light green||dark green||red||dark red||yellow||orange||pink||blue||dark blue||dark teal||white||clear||gold|
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!
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!
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...
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.