Go Down

Topic: serial.available()==0, doesn't wait for input (Read 2201 times) previous topic - next topic

tsiegel

 Serial.println("How many times do you want the Red LED to Blink?");  //ask for # red blinks
  while (Serial.available()==0){ }  //wait for input
  numRedBlinks=Serial.parseInt();  //input number of red blinks
 
  Serial.println("How many times do you want the Yellow LED to Blink?"); //ask for # yellow blinks
  while (Serial.available()==0){ }  // wait for input
  numYellowBlinks=Serial.parseInt();  //input number of red blinks

This code waits for the first while statement (red) but doesn't wait for input for the second (yellow). I copied and pasted on Arduino 1.8.5 software and it runs perfectly.

sandeepmistry

Hi @tsiegel,

Could you please share a full sketch that reproduces the issue. Plus, also let us know what board and OS you are using on the PC. Thanks.

ballscrewbob

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up