- المكونات الاساسية :
- Arduino UNO R3
- TCS3200 Color Sensor Module
- 5MM LED
- Breadboard
- Jumper Wires
---------------------------------------------------------------------
- مخطط الرسم البياني :
- تحميل الكود أردوينو :
// Project : Color Recognition TCS230 Sensor with Arduino UNO R3
// By : DIY Channel
// My Youtube Channel : https://www.youtube.com/c/DIYChannel2019
const int s0 = 8;
const int s1 = 9;
const int s2 = 10;
const int s3 = 11;
const int out = 12;
// دبابيس LED متصلة بـ Arduino
int redLed = 2;
int greenLed = 3;
int blueLed = 4;
int red = 0;
int green = 0;
int blue= 0;
void color()
{
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
digitalWrite(s3, HIGH);
blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
digitalWrite(s2, HIGH);
green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);
}
void setup()
{
Serial.begin(9600);
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()
{
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);
if (red < blue && red < green && red < 20)
{
Serial.println(" - (Red Color)");
digitalWrite(redLed, HIGH); // Turn RED LED ON
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, LOW);
}
else if (blue < red && blue < green)
{
Serial.println(" - (Blue Color)");
digitalWrite(redLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, HIGH); // Turn BLUE LED ON
}
else if (green < red && green < blue)
{
Serial.println(" - (Green Color)");
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH); // Turn GREEN LED ON
digitalWrite(blueLed, LOW);
}
else{
Serial.println();
}
delay(300);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, LOW);
}
-------------------------------------------------------------------------------------
color sensor,arduino,arduino color sensor,color sensor arduino,tcs230 color sensor connection with arduino,how to use the color sensor with arduino,color sensor with arduino auto shorting machine,tcs3200 color sensor,color recognition,control servo motor with color sensor,arduino uno,actuated motor with color sensor,arduino colour recognition,tcs230 color sensor arduino,arduino color,servo motor rotate with color sensor,tcs230 color sensor arduino code,color sensor project arduino
No comments:
Post a Comment