Colour Detector

Description
         
          A Color Sensor, as the name suggests, is a device that senses or detects colors. A color sensor will use an external means of emitting light and then analyse the reflected light from the object in order to determine its color. Color sensors will give an accurate color of the object. In this project, we are going to design a simple Arduino Color Sensor application, which has an ability to detect different colors. We have used TCS3200 color sensors for this purpose. Okey, Let's make it.

Components Required

 1. Arduino Nano  * 1
 2. TCS3200 Colour Sensor Module  * 1 
 3. LCD (16*2)  * 1
 4. Bread Board  * 1
 5. Jumper Wires         * 1

 Circuit Diagram












Program

digitalWrite(s0,HIGH);
digitalWrite(s1,HIGH);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
red = pulseIn(outPin, LOW); // Reading RED component of color
  
digitalWrite(s2, HIGH);
digitalWrite(s3, HIGH);
grn = pulseIn(outPin, LOW); // Reading GREEN component of color
    
digitalWrite(s2, LOW);
digitalWrite(s3, HIGH);
blu = pulseIn(outPin, LOW); // Reading BLUE component of color

void getColor()
{  
  readRGB();
       if (red > 8  && red < 18   &&  grn >  9 && grn < 19    &&  blu > 8  && blu < 16)   color = "WHITE";
  else if (red > 80 && red < 125  &&  grn > 90 && grn < 125   &&  blu > 80 && blu < 125)  color = "BLACK";
  else if (red > 12 && red < 30   &&  grn > 40 && grn < 70    &&  blu > 33 && blu < 70)   color = "RED";
  else if (red > 50 && red < 95   &&  grn > 35 && grn < 70    &&  blu > 45 && blu < 85)   color = "GREEN";
  else if (red > 10 && red < 20   &&  grn > 10 && grn < 25    &&  blu > 20 && blu < 38)   color = "YELLOW";
  else if (red > 65 && red < 125  &&  grn > 65 && grn < 115   &&  blu > 32 && blu < 65)   color = "BLUE";
  else  color = "NO_COLOR";
}