TCS3200 Color Sensor
Precise RGB color recognition for sorting machines, color-matching, and line-following projects.
Wiring & code for
TCS3200 practical reference
A color-frequency sensor used in color-sorting machines, line-following robots, and color-matching projects.
Key specifications
- Sensor type: TAOS TCS3200 programmable color light-to-frequency converter
- Operating voltage: 2.7V–5.5V (breakout modules run at 3.3V or 5V)
- Operating current: ~25-30 mA with onboard white LEDs active
- Photodiode array: 8x8 array: 16 red-filtered, 16 green-filtered, 16 blue-filtered, 16 clear (no filter)
- Output: Square-wave frequency proportional to detected light intensity, per selected color channel
- Output frequency range: 2 Hz to 500 kHz, set by S0/S1 scaling pins
- Sensing distance: ~5-10mm optimal (close-proximity sensing)
- Interface: Digital pulse frequency — read with pulseIn() or a hardware timer/counter, not analogRead()
Pinout and connection notes
S0/S1 output frequency scaling — these two pins set how fast OUT pulses, as a percentage of the sensor's maximum frequency: 00 = power down, 01 = 2%, 10 = 20%, 11 = 100%. Most projects use the 20% setting (S0=1, S1=0); 100% can outrun what pulseIn() can reliably capture on slower microcontrollers.
S2/S3 filter selection — these select which of the four photodiode types is active: 00 = red, 01 = blue, 10 = clear (no filter), 11 = green. Read all three color channels in sequence (switching S2/S3 between each) to build a full RGB reading — a single read only returns one channel.
Ambient light matters a lot — this sensor has no light shielding of its own, so results drift with room lighting unless the target is close (5-10mm) and, ideally, shielded from ambient light with a small enclosure or hood. Calibrate against a known white and black reference under your actual lighting setup rather than trusting raw frequency values.
OUT is a frequency, not a voltage — do not use analogRead() on this pin. Use pulseIn() to measure the pulse width and derive frequency, or better, an interrupt-driven pulse counter if your microcontroller supports one, since pulseIn() blocks and is slow for rapid color-cycling applications.
- VCC: Power, 3.3–5V DC depending on breakout
- GND: Ground
- S0: Output frequency scaling, bit 0 (paired with S1 — see pinout notes for the scaling table)
- S1: Output frequency scaling, bit 1
- S2: Photodiode filter select, bit 0 (paired with S3 — selects red/green/blue/clear)
- S3: Photodiode filter select, bit 1
- OUT: Frequency output — connect to a digital input pin capable of pulse timing
- OE / LED: Output enable (active LOW) on the bare IC; on most breakout boards this pin instead switches the onboard white LEDs
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Board Integration
Related