Spread the love















Arduino color recognition

RGB color detector – Color Recognition Sensor – TCS230 TCS3200

Parts Required:

– TCS230 TCS3200 Color Recognition Sensor

– Breadboard

– Arduino NANO v3.0

– Wires to connect it all together

Wiring your Color Sensor



Wiring your Color Sensor

// Hisham Marzouk

// www.Officialhrm.com

int s0_pin =2;

int s1_pin =3;

int s2_pin =4;

int s3_pin =5;

int out_pin =6;

void setup() {

Serial.begin(9600);

pinMode(s0_pin, OUTPUT);

pinMode(s1_pin, OUTPUT);

pinMode(s2_pin, OUTPUT);

pinMode(s3_pin, OUTPUT);

pinMode(out_pin, INPUT);

digitalWrite(s0_pin,HIGH);

digitalWrite(s1_pin,LOW);

}

void loop() {

digitalWrite(s2_pin,LOW);

digitalWrite(s3_pin,LOW);

int red_color = pulseIn(out_pin, LOW);

red_color = map(red_color, 25,72,255,0);

digitalWrite(s2_pin,HIGH);

digitalWrite(s3_pin,HIGH);

int green_color = pulseIn(out_pin, LOW);

green_color = map(green_color, 30,90,255,0);

delay(5);

digitalWrite(s2_pin,LOW);

digitalWrite(s3_pin,HIGH);

int blue_color = pulseIn(out_pin, LOW);

blue_color = map(blue_color, 25,70,255,0);

delay(30);

if (red_color >=0){

Serial.print(red_color *2);

Serial.print(“,”);

}else{

Serial.print(0);

Serial.print(“,”);

}

if (green_color >=0){

Serial.print(green_color*10);

Serial.print(“,”);

}else{

Serial.print(0);

Serial.print(“,”);

}

if (blue_color >=0){

Serial.print(blue_color*10);

}else{

Serial.print(0);

}

Serial.print(“,”);

Serial.println(0);

}

For more Please make sure to subscribe to Officialhrm YouTube channel and like Facebook Page.

Thank you for visiting Officialhrm! Please don’t forget to share this website with your friends.