Blogs
TCS3200 Color Sensor Module
TCS3200 Color Sensor Module
Precise RGB Color Detection for Arduino and Embedded Projects
Introduction
The TCS3200 Color Sensor is a programmable color light-to-frequency converter that combines configurable silicon photodiodes and a current-to-frequency converter. It can detect and measure the intensity of red, green, blue, and white light, making it ideal for color sorting, ambient light sensing, and industrial automation applications.
Key Features
RGB Detection
Measures red, green, and blue light separately
Programmable
Adjustable output frequency scaling (2%, 20%, 100%)
Fast Response
High-frequency output up to 600kHz
Easy Integration
Works with 3.3V or 5V systems including Arduino
Technical Specifications
Detection Range | 380nm-700nm (Visible Light Spectrum) |
---|---|
Photodiode Type | 16 photodiodes (4 red, 4 green, 4 blue, 4 clear) |
Output Frequency | 0Hz to 600kHz |
Supply Voltage | 2.7V – 5.5V DC |
Current Consumption | ~2mA (typical) |
Output Scaling | 2%, 20%, or 100% (programmable) |
Operating Temperature | -40°C to +85°C |
Pin Configuration

Pin | Label | Description | Arduino Connection |
---|---|---|---|
1 | VCC | Power (3.3V or 5V) | 5V |
2 | GND | Ground | GND |
3 | S0 | Frequency scaling selection | D2 |
4 | S1 | Frequency scaling selection | D3 |
5 | S2 | Photodiode type selection | D4 |
6 | S3 | Photodiode type selection | D5 |
7 | OUT | Frequency output | D6 |
8 | OE | Output enable (active low, optional) | GND (if not used) |
Note: The sensor requires proper lighting conditions for accurate color detection
Wiring with Arduino
1 2 3 4 5 6 7 8 9 10 11 |
// Basic Connections: // VCC → 5V // GND → GND // S0 → D2 // S1 → D3 // S2 → D4 // S3 → D5 // OUT → D6 // OE → GND (if used) // For best results, use consistent lighting and calibrate with known colors |
Important: Avoid direct sunlight as it may affect color readings
Basic Color Detection Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
// TCS3200 Color Sensor Basic Example #define S0 2 #define S1 3 #define S2 4 #define S3 5 #define OUT 6 void setup() { pinMode(S0, OUTPUT); pinMode(S1, OUTPUT); pinMode(S2, OUTPUT); pinMode(S3, OUTPUT); pinMode(OUT, INPUT); // Set frequency scaling to 20% digitalWrite(S0, HIGH); digitalWrite(S1, LOW); Serial.begin(9600); } void loop() { // Read Red component digitalWrite(S2, LOW); digitalWrite(S3, LOW); int red = pulseIn(OUT, LOW); // Read Green component digitalWrite(S2, HIGH); digitalWrite(S3, HIGH); int green = pulseIn(OUT, LOW); // Read Blue component digitalWrite(S2, LOW); digitalWrite(S3, HIGH); int blue = pulseIn(OUT, LOW); Serial.print("R: "); Serial.print(red); Serial.print(" G: "); Serial.print(green); Serial.print(" B: "); Serial.println(blue); delay(500); } |
Advanced Features
Frequency Scaling
1 2 3 4 5 6 7 8 9 10 11 12 |
// Set frequency scaling (S0, S1) // 2% scaling (low power) digitalWrite(S0, LOW); digitalWrite(S1, HIGH); // 20% scaling (recommended) digitalWrite(S0, HIGH); digitalWrite(S1, LOW); // 100% scaling (maximum) digitalWrite(S0, HIGH); digitalWrite(S1, HIGH); |
Color Filter Selection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Select photodiode type (S2, S3) // Red filter digitalWrite(S2, LOW); digitalWrite(S3, LOW); // Green filter digitalWrite(S2, HIGH); digitalWrite(S3, HIGH); // Blue filter digitalWrite(S2, LOW); digitalWrite(S3, HIGH); // No filter (clear) digitalWrite(S2, HIGH); digitalWrite(S3, LOW); |
Color Calibration
1 2 3 4 5 6 |
// Calibration with known colors void calibrate() { // Measure reference colors first // Store reference values in EEPROM // Compare new readings to references } |
Color Identification
1 2 3 4 5 6 7 |
// Simple color identification String getColorName(int r, int g, int b) { if (r > g && r > b) return "Red"; if (g > r && g > b) return "Green"; if (b > r && b > g) return "Blue"; return "Unknown"; } |
Troubleshooting
Inconsistent Readings
- Ensure stable lighting conditions
- Calibrate with known reference colors
- Check for sensor saturation (too bright)
No Output
- Verify power connections (3.3V/5V)
- Check frequency scaling settings
- Ensure OE pin is properly connected
Color Inaccuracy
- Use diffused lighting to prevent glare
- Maintain consistent distance to objects
- Implement proper calibration routine