Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based TCS3200 Color Sensor Interface

View and Edit Project In Cirkit DesignerImage 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

Arduino UNO

Wiring Details

TCS3200 Color Sensor

Arduino UNO

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.