TCS3200 Color Sensor

Overview

/media/uploads/weiyuli/sensor.jpg 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

/media/uploads/weiyuli/pinout.jpg

  • S0 and S1 are used to scale the output of the sensor. A table of the scaling follows:
S0S1scaling
LLdisable
LH2%
HL20%
HH100%
  • S2 and S3 select which channel to read the intensity from (R, G, B, All). Below is a table of the pin selection logic:
S2S3Channel
LLRED
LHBLUE
HLNO FILTER
HHGREEN
  • 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 pinTCS3200 pin
GNDGND
VOUTVCC
p25OUT
p24S3
p23S2
p22S1
p21S0
GNDLED

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 functionDescription
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

Repository: YWColorSensor

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.

/media/uploads/weiyuli/working.jpg


Please log in to post comments.