Hi All. I was rather surprised when I was not able to reproduce some simple example of switching RGB LED using the Arduino IDE whereas using Python the same code works as expected.
Is this a bug in Arduino IDE???
Can any one explain me the reason???
I call through Python:

The working Arduino code:
int redPin=8;
int greenPin=7;
int bluePin=6;
String myColor;
String msg="What color to switch?";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);
//digitalWrite(redPin,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(msg);
while (Serial.available()==0){
}
myColor=Serial.readString();
Serial.println(myColor);
if (myColor=="red"){
Serial.print(myColor);
digitalWrite(redPin,HIGH);
digitalWrite(greenPin,LOW);
digitalWrite(bluePin,LOW);
}
if (myColor=="blue"){
Serial.print(myColor);
digitalWrite(redPin,LOW);
digitalWrite(greenPin,LOW);
digitalWrite(bluePin,HIGH);
}
if (myColor=="green"){
Serial.print(myColor);
digitalWrite(redPin,LOW);
digitalWrite(greenPin,HIGH);
digitalWrite(bluePin,LOW);
}
}
