Lesson 17 Paul McWhorter Uno R4 wifi. Can't get the LED's to turn on. Checked the wiring with digitalWrite, LED's function manually. It seems like the program never executes the if statements. Reviewed the vid multiple times. Stumped. Hope this is the correct place to post this question. thank you.
int redPin=9;
int yellowPin=10;
int greenPin=11;
String userColor;
String userPrompt="Please select red, yellow, green LED color-";
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
pinMode(redPin,OUTPUT);
pinMode(yellowPin,OUTPUT);
pinMode(greenPin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//ASK
Serial.println (userPrompt);
//WAIT
while (Serial.available()==0) {
}
//READ
userColor=Serial.readString();
userColor.toLowerCase();
if (userColor=="red") {
digitalWrite (redPin,HIGH);
digitalWrite (yellowPin,LOW);
digitalWrite (greenPin,LOW);
Serial.println (userColor);
}
if (userColor=="yellow") {
digitalWrite (redPin,LOW);
digitalWrite (yellowPin,HIGH);
digitalWrite (greenPin,LOW);
Serial.println (userColor);
}
if (userColor=="green") {
digitalWrite (redPin,LOW);
digitalWrite (yellowPin,LOW);
digitalWrite (greenPin,HIGH);
Serial.println (userColor);
}
}