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 on the chart below. 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.
| Address |
Function |
| 0x03 |
Command |
| 0x04 |
Color Number |
| 0x05 |
Red Value |
| 0x06 |
Green Value |
| 0x07 |
Blue Value |
| 0x08 |
White Value |


 |
Sensor Documentation
All the information you need about Modern Robotics Sensors in one document.
PDF File
|
Note: If you are not sure what the mains A/C electric frequency is for your country, it can be found by clicking here.
Specifications
|
Power
|
5 Volt DC 20mA max
|
|
Standard 4 Pin Connector
|
4 pin I2C port
|
|
Logic Voltage Levels
|
Logic 0 - 0 Volts
Logic 1 – 5 Volts
|
|
Wiring Diagram
|
Black - Ground
White - SCL
Yellow - SDA
Red - +5V
|
|
I2C Address
|
0x3C
|
|
I2C Change Option
|
Yes
|
|
I2C Bus Speed
|
100KHz max
|
|
Operational Frequency
|
50Hz or 60Hz
|
|
Typical Maximum Range
|
7 Centimeters
|
|
Internal Sampling Rate
|
30 Samples Per Second
|
|
Unit Dimensions - LxWxH
|
32 x 32 x 11 Millimeters
|
|
Mounting Holes
|
24 x 24 Millimeter Square Pattern - designed for 8mm grid spacing
|
|
Unit Weight
|
10 Grams
|
|
Connecting Wire Length
|
25 Centimeters
|