color
Interfacing TCS3200 with Arduino Uno
What is the TCS3200?
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.
Setting Up TCS3200 with Arduino Uno
Library
None — built-in pulseIn() by —
No library needed; uses core Arduino functions only.
Wiring
| Component pin | Arduino Uno pin | Note |
|---|---|---|
| VCC | 5V | |
| GND | GND | |
| S0 | D4 | Frequency scaling, with S1: 2%/20%/100%. |
| S1 | D5 | |
| S2 | D6 | Color filter select, with S3. |
| S3 | D7 | |
| OUT | D8 | Square wave whose frequency is proportional to the selected color's intensity. |
| OE | — | Tie LOW (or leave unconnected — most breakouts pull it low by default) to enable output. |
Swipe sideways to see every column →
- Output is raw pulse-width timing, not an RGB value — shorter pulseIn() time means a stronger reading for that color filter. Converting this to real RGB (0-255) values needs a per-sensor calibration pass against known white/black references, since raw timings vary with ambient light and the specific sensor unit.
- The white/dark calibration LEDs on most breakout boards should be on for consistent readings — ambient lighting changes will otherwise skew results significantly.
- S0/S1 set the output frequency scaling (2%/20%/100%) as a tradeoff between read speed and resolution; 20% is a common default for hobbyist use.
Related Components
Related Guides & Projects
Arduino Uno R4 Minima Pinout: Every GPIO, ADC, DAC, and Op-Amp Pin Explained
A complete Arduino Uno R4 Minima pinout reference — digital I/O, ADC, DAC, op-amp, CAN, dual UART, and exactly what it leaves out compared to the WiFi variant.
Mastering PWM on Arduino: Dimming LEDs and Controlling Motors
Understand what PWM actually is on Arduino, dim an LED smoothly, and safely control a DC motor's speed with a driver chip -- plus the mistakes (like wiring a motor straight to a pin) that damage boards.
4-Digit 7-Segment Counter with TM1637 & Arduino
Drive a TM1637-based 4-digit 7-segment display with Arduino Uno to show a real-time up/down counter, elapsed timer, and scrolling text. Covers library setup, brightness control, and custom segment mapping.
Arduino Uno R4 Minima vs WiFi: Which One Should You Choose?
Same processor, same memory, different price. Here's what the WiFi variant's extra hardware actually gets you, and when the Minima is the smarter buy.