Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based TCS3200 Color Sensor Interface

Image of Arduino UNO Based TCS3200 Color Sensor Interface

Circuit Documentation

Summary of the Circuit

This circuit integrates a TCS3200 color sensor with an Arduino UNO microcontroller. The TCS3200 color sensor is capable of detecting the color of a surface and providing a frequency output proportional to the intensity of the color. The Arduino UNO reads these frequencies and processes them to determine the color detected by the sensor. The circuit is designed to measure the frequency of the red, green, and blue components of the light absorbed by the color sensor and output these values through the Arduino's serial interface.

Component List

TCS3200 Color Sensor

  • Description: A color sensor that can detect and measure a wide range of colors.
  • Pins: GND, OUT, S2, S3, VCC, LED, S0, S1

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P, widely used for prototyping and educational purposes.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0

Wiring Details

TCS3200 Color Sensor

  • GND: Connected to Arduino UNO GND
  • OUT: Connected to Arduino UNO Digital Pin 8 (D8)
  • S2: Connected to Arduino UNO Digital Pin 7 (D7)
  • S3: Connected to Arduino UNO Digital Pin 6 (D6)
  • VCC: Connected to Arduino UNO 5V
  • S0: Connected to Arduino UNO Digital Pin 4 (D4)
  • S1: Connected to Arduino UNO Digital Pin 5 (D5)

Arduino UNO

  • GND: Connected to TCS3200 GND
  • Digital Pin 8 (D8): Connected to TCS3200 OUT
  • Digital Pin 7 (D7): Connected to TCS3200 S2
  • Digital Pin 6 (D6): Connected to TCS3200 S3
  • 5V: Connected to TCS3200 VCC
  • Digital Pin 4 (D4): Connected to TCS3200 S0
  • Digital Pin 5 (D5): Connected to TCS3200 S1

Documented Code

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// TCS230 or TCS3200 pins wiring to Arduino
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

void setup() {
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  
  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);
  
  // Setting frequency scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);
  
   // Begins serial communication 
  Serial.begin(9600);
}

void loop() {
  // Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  
  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);
  
   // Printing the RED (R) value
  Serial.print("R = ");
  Serial.print(redFrequency);
  delay(100);
  
  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the GREEN (G) value  
  Serial.print(" G = ");
  Serial.print(greenFrequency);
  delay(100);
 
  // Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the BLUE (B) value 
  Serial.print(" B = ");
  Serial.println(blueFrequency);
  delay(100);
}

This code is designed to operate the TCS3200 color sensor with the Arduino UNO. It initializes the sensor, sets the frequency scaling, and reads the frequency of the red, green, and blue light components. The frequencies are then printed to the serial monitor, allowing the user to observe the color detected by the sensor.