int redPin = 12;
int greenPin = 11;
int bluePin = 10;
int waitT = 250;
String msg = "What color do you want?(1 = R,2 = G,3 = B) ";
int choice;
int pin;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(msg);
Serial.print("Serial availability: ");
Serial.println(Serial.available());
while(Serial.available() == 0){
}
choice = Serial.parseInt();
/*if the serial monitor is not restarted, Serial.available() will
return 1 instead of 0 and the while loop will be skipped on even
numbered void loops. Find a better way to make Serial.available()
return 0.*/
/*Serial.end();
Serial.begin(9600);*/
while(Serial.available() != 0){
Serial.parseInt();
}
switch(choice){
case 1:
pin = redPin;
break;
case 2:
pin = greenPin;
break;
case 3:
pin = bluePin;
break;
}
for(int i = 0; i < 3; i++){
digitalWrite(pin, HIGH);
delay(waitT);
digitalWrite(pin, LOW);
delay(waitT);
}
delay(1000);
}