COLOR RECOGNITION SENSOR

TINKS034

  1. The TCS3200 Color Recognition Sensor Module uses a high-quality light sensor allowing you to sense any color through a combination of Red, Green, and Blue.
  2. The sensor provides a Digital as well as Analog output.
Features:-
  1. Compact design
  2. Power down Feature
  3. High-Resolution Conversion of Light Intensity to Frequency
  4. Programmable Color and Full-Scale Output Frequency
  5. Communicates Directly With a Microcontroller
  6. Single-Supply Operation (2.7 V to 5.5 V)
  7. 54mm pitch connector pin-out
  8. Stable 200 ppm/°C Temperature Coefficient
  9. Output:- analog and digital
Applications:-
  1. True color recognition.
  2. Color mark detection.

    

int S0=8;
int S1=9;
int S2=11;
int S3=12;
int sensorOut=10;
int frequency = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);

// Setting frequency-scaling to 20%
digitalWrite(S0,HIGH);
digitalWrite(S1,LOW);

Serial.begin(9600);
}
void loop() {
// Setting red filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping the value of the frequency to the RGB Model of 0 to 255
frequency = map(frequency, 25,72,255,0);
// Printing the value on the serial monitor
Serial.print("R= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(100);
// Setting Green filtered photodiodes to be read
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping the value of the frequency to the RGB Model of 0 to 255
frequency = map(frequency, 30,90,255,0);
// Printing the value on the serial monitor
Serial.print("G= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(100);
// Setting Blue filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
//Remaping the value of the frequency to the RGB Model of 0 to 255
frequency = map(frequency, 25,70,255,0);
// Printing the value on the serial monitor
Serial.print("B= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.println(" ");
delay(100);
}