RGB diode programe

Hi
I have spent the last three nights trying to debug this sketch and getting no where. Every time i run the program i am prompted for a color. I am getting a reply back saying that is not a valid color.
Sorry in advance if i am in the wrong section and can any one direct me where to get help.
:frowning:
Serial.begin(9600); //Turn on Serial port
pinMode(redPin, OUTPUT); //Set redPin to be an output
pinMode(greenPin, OUTPUT); //Set greenPin to be an output
pinMode(bluePin, OUTPUT); //set bluePin to be an output

}

void loop() {

Serial.println("What color would you like the LED? (red, green, or blue)"); //Prompt user for color
while (Serial.available()==0) { } //Wait for input
colorChoice = Serial.readString();

if (colorChoice=="red") {

analogWrite(redPin, brightness); //turn on red pin
analogWrite(greenPin, 0); //turn off green pin
analogWrite(bluePin, 0); //write off blue pin
}

if (colorChoice=="blue") {

analogWrite(redPin, 0); //turn off red pin
analogWrite(greenPin, 0); //turn off green pin
analogWrite(bluePin, brightness); //write on blue pin
}

if (colorChoice=="green") {

analogWrite(redPin, 0); //turn off red pin
analogWrite(greenPin, brightness); //turn on green pin
analogWrite(bluePin, 0); //write off blue pin
}

if (colorChoice!="red" && colorChoice!="green" && colorChoice!= "blue") {
Serial.println("That is not a valid color choice, please try again");
Serial.println("");
}

}

Have you set a line ending in serial monitor? In the "not valid" part of the code, you should print the value actually received. You should also use "else" with your "if" statements.

You need double " =="s in a comparison:

if (colorChoice!=="red" && colorChoice!="green" && colorChoice!= "blue") {