Arduino RGB Color Detector using TCS3200 Color Sensor

Arduino RGB Color Detector using TCS3200 Color Sensor (Last Updated On: December 5, 2018)

Introduction:

Thus Arduino RGB Color Detector using TCS3200 Color Sensor is a wonderful project for students who want to have fun with too many colors. In this Project we will be “Interfacing TCS3200 Color Sensor with Arduino” for designing a simple color detector.

Experimental Set Up has been designed specifically for detecting frequncy of RGB color. The LCD panel directly displays the frequency of RGB color. As the combination of all these colors gives different color. There are various software available which directly converts the combination of RGB frequency into desired color. The set up is absolutely self contained and requires no other apparatus.




Components Required:

For designing Arduino RGB Color Detector using TCS3200 Color Sensor we use the following components. Each and every components are described below further.

1. Arduino UNO Board
2. TCS3200 Color Sensor - (Buy Online from Amazon)
3. 16*2 LCD (example JHD162)
4. 3 different LED (RED, BLUE, GREEN)
5. Breadboard
6. Connecting Wires
7. Red, Blue, Green Color paper

Components Description

What is TCS3200 Color Sensor

TCS3200 RGB Color Sensor For Arduino is a complete color detector, including a TAOS TCS3200 RGB sensor chip and 4 white LEDs. The TCS3200 can detect and measure a nearly limitless range of visible colors. Applications include test strip reading, sorting by color, ambient light sensing and calibration, and color matching, to name just a few.

Arduino RGB Color Detector using TCS3200 Color Sensor

The TCS3200 RGB Color Sensor For Arduino has an array of photo detectors, each with either a red, green, or blue filter, or no filter (clear). The filters of each color are distributed evenly throughout the array to eliminate location bias among the colors. Internal to the device is an oscillator which produces a square-wave output whose frequency is proportional to the intensity of the chosen color.

The TCS3200 color sensor can detect a wide variety of colors based on their wavelength. This sensor is specially useful for color recognition projects such as color matching, color sorting, test strip reading and much more.

Features of TCS3200 Color Sensor

1. Single-Supply Operation (2.7V to 5.5V)
2. High-Resolution Conversion of Light Intensity to Frequency
3. Programmable Color and Full-Scale Output Frequency
4. Power Down Feature
5. Communicates Directly to Microcontroller
6. S0~S1: Output frequency scaling selection inputs 
7. S2~S3: Photodiode type selection inputs
8. OUT Pin: Output frequency
9. OE Pin: Output frequency enable pin (active low), can be impending when using
10. Support LED lamp light supplement control
11.Size: 28.4x28.4mm

Specifications & Pin Details:

Arduino RGB Color Detector using TCS3200 Color Sensor



Arduino RGB Color Detector using TCS3200 Color Sensor

Assemble the Circuit as shown in the following figure. This figure or Circuit Diagram is for “Interfacing TCS3200 Color Sensor with Arduino” or simply designing “Arduino RGB Color Detector using TCS3200 Color Sensor”.

Arduino RGB Color Detector using TCS3200 Color Sensor


Working Explanation:

The TCS230 senses color light with the help of an 8 x 8 array of photodiodes. Then using a Current-to-Frequency Converter the readings from the photodiodes are converted into a square wave with a frequency directly proportional to the light intensity. Finally, using the Arduino Board we can read the square wave output and get the results for the color.

To TCS3002D, when choose a color filter, it can allow only one particular color to get through and prevent other color. For example, when choose the red filter, Only red incident light can get through, blue and green will be prevented. So we can get the red light intensity. Similarly ,when choose other filters we can get blue or green light.

TCS3002D has four photodiode types. Red , blue, green and clear, reducing the amplitude of the incident light uniformity greatly, so that to increase the accuracy and simplify the optical. When the light project to the TCS3002D we can choose the different type of photodiode by different combinations of S2 and S3. Look at the form as follows.

Arduino RGB Color Detector using TCS3200 Color Sensor

TCS3002D can output the frequency of different square wave (occupies emptiescompared 50%),different color and light intensity correspond with different frequency of square wave. There is a relationship between the output and light intensity. The range of the typical output frequency is 2HZ~500KHZ. We can get different scaling factor by different combinations of S0 and S1. Look at the form as follows.

Arduino RGB Color Detector using TCS3200 Color Sensor


Source Code: Interfacing TCS3200 Color Sensor with Arduino

Simply copy this code and upload to the Arduino board. Make sure to have the same connection as indicated above in the circuit diagram of Arduino RGB Color Detector using TCS3200 Color Sensor.

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);//RS,EN,D4,D5,D6,D7

const int s0 = 8;  
const int s1 = 9;  
const int s2 = 10;  
const int s3 = 11;  
const int out = 12;   
// LED pins connected to Arduino
int redLed = 16;  
int greenLed = 15;  
int blueLed = 14;
// Variables  
int red = 0;  
int green = 0;  
int blue = 0;  
    
void setup()   
{  
  Serial.begin(9600); 
  lcd.begin(16, 2);
  pinMode(s0, OUTPUT);  
  pinMode(s1, OUTPUT);  
  pinMode(s2, OUTPUT);  
  pinMode(s3, OUTPUT);  
  pinMode(out, INPUT);  
  pinMode(redLed, OUTPUT);  
  pinMode(greenLed, OUTPUT);  
  pinMode(blueLed, OUTPUT);  
  digitalWrite(s0, HIGH);  
  digitalWrite(s1, HIGH);  
}  
    
void loop() 
{  
   lcd.setCursor(0, 0);
  lcd.print(" Color Detected ");//printing name 
  color(); 
  Serial.print("R Intensity:");  
  Serial.print(red, DEC);  
  Serial.print(" G Intensity: ");  
  Serial.print(green, DEC);  
  Serial.print(" B Intensity : ");  
  Serial.print(blue, DEC);  
  //Serial.println();  

  if (red < blue && red < green && red < 20)
  {  
   Serial.println(" - (Red Color)");
    lcd.setCursor(0, 1);  
   lcd.print("    RED Color   ");
   delay(500);
   digitalWrite(redLed, HIGH); // Turn RED LED ON 
   digitalWrite(greenLed, LOW);  
   digitalWrite(blueLed, LOW);  
  }  

  else if (blue < red && blue < green)   
  {  
   Serial.println(" - (Blue Color)"); 
   lcd.setCursor(0, 1);
   lcd.print("   Blue Color   ") ;
   delay(500);
   digitalWrite(redLed, LOW);  
   digitalWrite(greenLed, LOW);  
   digitalWrite(blueLed, HIGH); // Turn BLUE LED ON  
  }  

  else if (green < red && green < blue)  
  {  
   Serial.println(" - (Green Color)"); 
   lcd.setCursor(0, 1); 
   lcd.print("   Green Color   ");
   delay(500);
   digitalWrite(redLed, LOW);  
   digitalWrite(greenLed, HIGH); // Turn GREEN LED ON 
   digitalWrite(blueLed, LOW);  
  }  
  else{
  Serial.println();
  lcd.setCursor(0, 1); 
  lcd.print(" Can't Identify"); 
  delay (500); 
  }   
  digitalWrite(redLed, LOW);  
  digitalWrite(greenLed, LOW);  
  digitalWrite(blueLed, LOW);  
 }  
    
void color()  
{    
  digitalWrite(s2, LOW);  
  digitalWrite(s3, LOW);  
  //count OUT, pRed, RED  
  red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);  
  digitalWrite(s3, HIGH);  
  //count OUT, pBLUE, BLUE  
  blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);  
  digitalWrite(s2, HIGH);  
  //count OUT, pGreen, GREEN  
  green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);  
}

Video Preview and Explanation:



Recommended For You

About the Author: Alex Newton

7 Comments

  1. My LCD screen seems very dim when connected up and the LEDs flash very dimly when the colour is detected, any idea why?

Ask A Question .......

Close