Pretty straight forward code, user asks for input and then gets results.
Using Arduino ide 2.2.1 on PC i core 5 ,Windows 10 home.
So when I use this code, it turns on pin 10 no matter what i put in ,red, green, blue.
Also I have tried it with a second Arduino and same results, also the computer sees the Uno as com3 but when i plug in a different one it sees it as com6.
Positively no problem with the wiring of this RGB led. If I take 5 vdc to each led through a 330 ohm resistor they all light up correctly.
Short of trying a third board, I am lost . I know that there is no issue with crossed wires because I tested as above . Just wondering if I got static electric that may have messed up the IC.
int redPin=8;
int greenPin=9;
int bluePin=10;
String msg= "What color led do you want on ?" ;
String myColor;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(msg);
while(Serial.available()==0){
}
myColor=Serial.readString();
if (myColor==redPin)
digitalWrite(redPin,HIGH);
digitalWrite(greenPin,LOW);
digitalWrite(bluePin,LOW);
if(myColor==greenPin);
digitalWrite(redPin,LOW);
digitalWrite(greenPin,HIGH);
digitalWrite(bluePin,LOW);
if(myColor==bluePin);
digitalWrite(bluePin,HIGH);
digitalWrite(redPin,LOW);
digitalWrite(greenPin,LOW);
}