شحن مجاني للأوردرات فوق
1000 ج
رمضان كريم
Precise RGB Color Detection for Arduino and Embedded Projects
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 FeaturesMeasures red, green, and blue light separately
Adjustable output frequency scaling (2%, 20%, 100%)
High-frequency output up to 600kHz
Works with 3.3V or 5V systems including Arduino
| 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 | 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) |
// 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
// 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);
}
// 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);
// 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);
// Calibration with known colors
void calibrate() {
// Measure reference colors first
// Store reference values in EEPROM
// Compare new readings to references
}
// 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";
}
No account yet?
Create an Account
Recent Comments