TCS3200 Color Sensor
Overview
The TCS 3200 Color Sensor is a sensor that uses a switchable photoresist to capture the intensity of color (specific wavelengths of light) as a current. The internals of the sensor then use a current to frequency converter to output a pulsetrain. The sensor uses Pulse Density Modulation to indicate levels of intensity. I.e. a more intense "green" will have a higher pulse density than a darker shade of green. The output of the sensor can be read in as a digital input, and with interrupt handling, can be polled properly. Some example uses of this sensor may include line following application, sorting by color, and detecting changes in environment.
Wiring the TCS3200 Color Sensor
Pin Description
- S0 and S1 are used to scale the output of the sensor. A table of the scaling follows:
S0 | S1 | scaling |
---|---|---|
L | L | disable |
L | H | 2% |
H | L | 20% |
H | H | 100% |
- S2 and S3 select which channel to read the intensity from (R, G, B, All). Below is a table of the pin selection logic:
S2 | S3 | Channel |
---|---|---|
L | L | RED |
L | H | BLUE |
H | L | NO FILTER |
H | H | GREEN |
- OE enables the output on active low. This pin allows a user to turn the device on or off to save power.
- OUT is the output pin. The PDM signal is read on this output.
- GND is the Ground pin.
- VCC connects to 2.7-5.0V. The 3.3V Vout pin on the mbed should work fine.
Connecting to the mbed
mbed pin | TCS3200 pin |
---|---|
GND | GND |
VOUT | VCC |
p25 | OUT |
p24 | S3 |
p23 | S2 |
p22 | S1 |
p21 | S0 |
GND | LED |
Datasheet
http://www.dfrobot.com/image/data/SEN0101/TCS3200%20TCS3210.pdf
Library Code
Import libraryTCS3200
This is the library to use the TCS3200 on the mbed
member function | Description |
---|---|
getRed() | returns the red intensity |
getGreen() | returns the green intensity |
getBlue() | returns the blue intensity |
getReading() | obtains a reading from the sensor |
incCount() | internal interrupt handler |
poll() | wrapper for getReading() |
Helloworld Example Code
Things to watch out for
- The ColorSensor constructor must be declared inside the main function, otherwhise the sensor will not poll properly.
- The sensor I received had intermittent connection issues. Make sure you have a stable power supply and connection
- Some sensors include an LED pin and an additional GND. This is to allow external power to the LED.
Please log in to post comments.