Color sensor with blue and green highrise cubes

We are having trouble getting the color sensor to distinguish between the blue and green highrise cubes. We have many color sensors, that all have updated firmware, and they all yield the same result. Most of the time they think the green cubes are blue. We have tried using the sensors in color mode, and hue mode, and have also tried using getColorBlueChannel and getColorGreenChannel. So far no setting can be relied on to return the correct block color. In brighter light the results are better, but still not reliable. Are we missing something?

Hi jrp62,

There is a sample program in ROBOTC called “Chameleon with Touch LED” that is very helpful for testing the Color Sensor. You can access this program by going to File > Open Sample Program. This program makes the Touch LED illuminate the same color as what is seen by the Color Sensor (broken down into 12 discrete “steps”).

After you download and run the program, what color does the Touch LED illuminate when you point the Color Sensor at the red, green, and blue cubes? Is the Touch LED exactly red on the red cube or does it appear to be red-orange? Or red-purple?

Depending on what type of light is in a room (incandescent, fluorescent, LED, sunlight, etc), the colors of objects seen by the Color Sensor can slightly shift. This is because light that looks white from a light bulb or the sun actually contains a lot of different color wavelengths. Some types of lights contain more of one color than another. While sunlight has a pretty even assortment of colors, some man-made lights are not as even.

If a particular light has a lot of yellow and green wavelengths, then this light will bounce off objects in that room and travel into the Color Sensor. The Color Sensor will see more yellow/green than usual, so the color it sees will shift a little. A red object may appear as red-orange due to the increased yellow light.

To solve the problem, you can widen the range of acceptable colors when looking for a red, green, or blue cube. So instead of only looking for a cube that is exactly red, you can look for a red or red-orange object to find the red cube.


  • Art

Same results with that test program. Red is fine. Green and blue are the problem. The lighting does make a difference. CFLs tend to see them both as green or greenish. LEDs tend to see them both as blue or blueish. In darker conditions both types of lights make the blocks look blue to the sensor.