I know this must be a newbie error, but for the life of me, I can't see why the second request for INT input is ignored.
The following code asks two(2) sequential input questions and reads the int input "before moving on to the nest code":
void loop(){
Serial.println(" How many times do you want the red led to blink");
while (Serial.available()==0){} //wait for input
numblinkredled = Serial.parseInt(); //read input
Serial.println(" How many times do you want the green led to blink");
while (Serial.available()==0){} //wait for input
numblinkgreenled = Serial.parseInt(); //read input
A "for" loop count code is used to complete the program
The result is as follows:
it asks for the red blink number;
it reads the int input;
it asks for the green blink number;
it DOES NOT READ THE GREEN INT INPUT; //it does not wait for INT input
it completes the red blink count;
it does not do a green count
it starts the loop over again
The issue seems to be the second "WHILE loop" is being ignored. Help anyone?
thanks
I hate to take your time, but I'm a newbie so here is the complete code I'm working with:
void loop(){
Serial.println(" How many times do you want the red led to blink");
while (Serial.available()==0){} //wait for input
numblinkredled = Serial.parseInt(); //read input
Serial.println(" How many times do you want the green led to blink");
while (Serial.available()==0){} //wait for input
numblinkgreenled = Serial.parseInt(); //read input
Serial.println(" ");
Serial.println(redmessage);
for(int j=1; j<=numblinkredled; j=j+1){ //counter
Serial.print(" You are on blink #: ");
Serial.println(j); //print increment
digitalWrite(redled,HIGH); // red led on
delay(redon); // led on time
digitalWrite(redled,LOW); // red off
delay(redoff); // led off time
}
Serial.println(greenmessage);
for(int j=1; j<=numblinkgreenled; j=j+1){
Serial.print(" You are on blink #: ");
Serial.println(j);
digitalWrite(greenled,HIGH);
delay(greenon);
digitalWrite(greenled,LOW);
delay(greenoff);
}
Serial.println(" ");
}