My daughter is working on a program using an IQ color sensor as part of her science fair project. Basically she wants to read the RGB 0-255 values out and display them on the LCD, while also turning the touch LED to the sensed color.
Here is her current robotc code:
#pragma config(Sensor, port4, colorDetector, sensorVexIQ_ColorHue)
#pragma config(Sensor, port3, touchLED, sensorVexIQ_LED)
task main()
{
setColorMode(colorDetector, colorTypeRGB_Hue_Ambient);
setTouchLEDRGB(touchLED, 0, 255, 0);
while(true)
{
if(getTouchLEDValue(touchLED) == 1) //Touch LED is not pressed
{
long redvalue = getColorRedChannel(colorDetector);
long greenvalue = getColorGreenChannel(colorDetector);
long bluevalue = getColorBlueChannel(colorDetector);
displayTextLine(1,“Red = %d”, redvalue);
displayTextLine(2,“Green = %d”, greenvalue);
displayTextLine(3,“Blue = %d”, bluevalue);
setTouchLEDRGB(touchLED, redvalue, greenvalue, bluevalue); //Set detected color
}
sleep(25);
}
}
The problem we’re seeing is this: If we put black in front of the sensor, it generally does a good job and gets 0,0,0 or close to it. However, when we put white in front of it, the values are non-zero, but I expected to see close to 255,255,255. Even if it were in the 240s, I’d say it’s OK. But we are seeing values in the 30-40 range most of the time. If we put red in front, the red value is definitely the highest value, and the same with Blue or Green, but they are never above 100, much less 200.
I tried changing the color mode to the colorTypeRGB_Hue_Reflected instead of ambient, and also tried colorTypeRGB_Raw_Reflected (and ambient), but it doesn’t seem to make a difference.
I can’t seem to find a calibration routine, is there one for the color sensor?
Anyone have any ideas or experience with this? Maybe we are missing something important.