Back to Sensors & Actuators Series

TCS3200 Programmable Color Light-to-Frequency Sensor

April 10, 2026 Wasil Zafar 8 min read

TCS3200 deep dive — photodiode filter array, frequency output principle, RGB calibration, color-space mapping, complete code, and sorting applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

Working Principle

The TCS3200 (and earlier TCS230) is a programmable color light-to-frequency converter. It contains an 8×8 array of photodiodes with four types of filters: 16 red, 16 green, 16 blue, and 16 clear (no filter). Two select pins (S2, S3) choose which filter group is active. The current from selected photodiodes drives a current-to-frequency converter, outputting a square wave whose frequency is proportional to light intensity of the selected colour channel.

Analogy: Imagine looking through coloured glasses — red glasses block everything except red light. The TCS3200 has three pairs of glasses and counts how many photons get through each.

Electrical Characteristics

ParameterValue
Supply Voltage2.7 V – 5.5 V
OutputSquare wave (frequency proportional to intensity)
Colour ChannelsRed, Green, Blue, Clear
Photodiode Array8 × 8 (64 photodiodes)
Frequency Scaling2%, 20%, 100% (selectable via S0, S1)
Non-linearity0.2% at 50 kHz
Dark Frequency12 Hz typical
PackageSOIC-8 (chip) or GY-31 module (with LEDs)

Interfacing with an MCU

The TCS3200 module (GY-31) has pins: VCC, GND, S0, S1 (frequency scaling), S2, S3 (filter selection), OUT (frequency), and OE (output enable, usually tied LOW). Four white LEDs illuminate the target object.

Wiring (Arduino): VCC → 5 V, GND → GND, S0 → Pin 4 (HIGH), S1 → Pin 5 (HIGH = 100% scaling), S2 → Pin 6, S3 → Pin 7, OUT → Pin 8.

Calibration

Colour accuracy depends on white-balance calibration:

  • White reference: Place a white card at the sensor distance; read R, G, B frequencies. These represent maximum reflectance per channel.
  • Black reference: Block all light; read R, G, B to determine the noise floor.
  • Mapping: R_mapped = map(R_raw, R_black, R_white, 0, 255) — repeat for G and B.
  • Consistent lighting: The on-board LEDs provide fixed illumination; ambient light introduces error — shade the sensor.

Code Example

/*
 * TCS3200 Color Sensor — Arduino
 * Wiring: S0→4, S1→5, S2→6, S3→7, OUT→8
 */
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define OUT_PIN 8

void setup() {
    Serial.begin(9600);
    pinMode(S0, OUTPUT); pinMode(S1, OUTPUT);
    pinMode(S2, OUTPUT); pinMode(S3, OUTPUT);
    pinMode(OUT_PIN, INPUT);

    /* Frequency scaling to 20% */
    digitalWrite(S0, HIGH); digitalWrite(S1, LOW);
    Serial.println("TCS3200 Color Sensor Ready");
}

int readColor(bool s2, bool s3) {
    digitalWrite(S2, s2); digitalWrite(S3, s3);
    delay(20);
    return pulseIn(OUT_PIN, LOW);  /* Period ∝ 1/frequency */
}

void loop() {
    int red   = readColor(LOW, LOW);
    int green = readColor(HIGH, HIGH);
    int blue  = readColor(LOW, HIGH);

    Serial.print("R: "); Serial.print(red);
    Serial.print(" G: "); Serial.print(green);
    Serial.print(" B: "); Serial.println(blue);

    /* Simple colour classifier */
    if (red < green && red < blue) Serial.println("  → RED");
    else if (green < red && green < blue) Serial.println("  → GREEN");
    else if (blue < red && blue < green) Serial.println("  → BLUE");
    else Serial.println("  → UNCLEAR");

    delay(500);
}

Real-World Applications

Manufacturing

Industrial Colour Sorting

Conveyor-belt sorting systems use TCS3200 sensors to classify objects by colour at rates of 10+ items per second. Red, green, and blue readings are fed to a classifier that triggers pneumatic actuators to divert items into correct bins — used in food grading (fruit ripeness), recycling (plastic colour), and pharmaceutical packaging.

SortingQuality ControlAutomation

Limitations

  • Ambient light sensitivity: External light sources shift readings — enclose the sensor and object in a light-proof chamber.
  • No true spectroscopy: Reports broad R/G/B bands, not narrow wavelengths — cannot distinguish metameric colours.
  • Distance dependent: Reading changes with target distance; maintain a fixed sensor-to-object gap.
  • Glossy surfaces: Specular reflections from shiny objects skew colour readings — matte targets are ideal.