Skip to content

Instantly share code, notes, and snippets.

@pankaj-gecko
Created January 27, 2022 11:53
Show Gist options
  • Save pankaj-gecko/8d9c4f795f7a930a3ca223c20fe70f1e to your computer and use it in GitHub Desktop.
Save pankaj-gecko/8d9c4f795f7a930a3ca223c20fe70f1e to your computer and use it in GitHub Desktop.
String myColor;
String yellowColor="yellow";
String blueColor="blue";
String greenColor="green";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
Serial.println("Enter the color you want to display : ");
while (!Serial.available()) {
}
myColor = Serial.readString();
Serial.print(myColor);
if (myColor.equals(yellowColor)) {
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
Serial.println("I am Yellow");
}
if (myColor.equals(blueColor)) {
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
Serial.println("I am Blue");
}
if (myColor.equals(greenColor)) {
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
Serial.println("I am Green");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment