Pausing program until user input with while loop not working

This is my first post here so I apologize if my formatting is off

I’ve written a program that’s supposed to blink a red and yellow LED a certain number of times, depending on what the user inputs. To stop the program while the user enters the data I’ve used two while loops (as shown in the code below). It works for entering the number of times the first (Red) led should blink but the second one dosen’t pause the code at all and after prompting the user for data just immediatley skips to blinking the lights, which is pretty much just the red led because it dosen’t give you a chance to enter the number of times the yellow led should blink.

Here’s the code:

int YellowLed = 9;
int RedLed=10;
int On=250;
int Off=250;
String RedMessage="The red LED is blinking";
String YellowMessage="The yellow LED is blinking";
int YBlink;
int RBlink;
void setup() {
  pinMode(YellowLed,OUTPUT);
  pinMode(RedLed,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  Serial.println("How many times should the Red LED blink?");
  while(Serial.available()==0){}
  RBlink=Serial.parseInt();

  Serial.println("How many times should the Yellow LED blink?");
  while(Serial.available()==0){}
  YBlink=Serial.parseInt();

  Serial.println(RedMessage);
  for(int i=1;i<=RBlink;i++){
    Serial.print("Blink #:");
    Serial.println(i);
    digitalWrite(RedLed,HIGH);
    delay(On);
    digitalWrite(RedLed,LOW);
    delay(Off);
    }
  Serial.println(YellowMessage);   
  for(int j=1;j<=YBlink;j++){
    Serial.print("Blink #:");
    Serial.println(j);
    digitalWrite(YellowLed,HIGH);
    delay(On);
    digitalWrite(YellowLed,LOW);
    delay(Off);
    }  
}

EDIT: Ok guys thanks I figured it out. I had the Serial Monitor set to Newline and that was messing things up. Thanks for the help!

What have you got the Line ending set to in the Serial monitor ?

what do you have as a line ending in your serial monitor ? Before we get into a complete Serial reception thing, because with the method you chose you are only reading one character at the time, and if that is not an integer, parseInt will just return 0, check out Robin’s example topic on Serial basics.

Also there is a simple user-input example in Planning and Implementing a Program

...R

bookmarked for future reference.