The Color Sensor detects the color of a target and returns values identifying the color.
The Color Sensor operates in two modes, Active and Passive. The mode can be selected by writing the required mode code to the Command register.
In Active mode, the internal LED provides the light source for detecting the target color. Best results in Active mode are obtained when the target is within about 7cm of the color sensor.
In Passive mode, the internal LED is switched off and the sensor detects the color of the light from an external light source such as a colored LED or lighted device.
The Color Number returned is in the range 0 – 16 as shown this chart. The sensor also returns values for red, green, blue and white.
The Color sensor I2C bus address is 0x3C.
Color Sensor Programming
To use the color sensor set the mode (default 0x00 Active mode) and then read 0x04 to get the color number and optionally 0x05 – 0x08 to get individual color channel values.
If you are not sure what the mains A/C electric frequency is for your country, it can be found here.