2 question on the Serial screen

I try to learning Arduino
and in a learning video from Poul McWhorter i have this
code :

void loop() {
Serial.println("How Many Times Do You Want the Red LED to blink?"); //Prompt User for Input

while(Serial.available()==0) {}
numRedBlinks=Serial.parseInt(); //Read the data the user has input

Serial.print("antal rød = ");
Serial.println(numRedBlinks);
Serial.println("How Many Times Do You Want the yellow LED to blink?"); //Prompt User for Input

while(Serial.available()==0) {} // Wait for User to Input Data
numYellowBlinks=Serial.parseInt(); //Read the data the user has input

Serial.println(redMessage);
for (int j=1; j<=numRedBlinks; j=j+1) { // Start our for loop
Serial.print(" You are on Blink #: ");
Serial.println(j);
digitalWrite(redLEDPin,HIGH); //Turn red LED on
delay(redOnTime); //Leave on for redOnTime
digitalWrite(redLEDPin,LOW); //Turn red LED off
delay(redOffTime); //Leave off for redOffTim
Serial.println(" ");
Serial.println(yellowMessage);
for (int j=1; j<=numYellowBlinks; j=j+1) { // Start our for loop
Serial.print(" You are on Blink #: ");
Serial.println(j);
digitalWrite(yellowLEDPin,HIGH); //Turn yellow LED on
delay(yellowOnTime); //Leave on for yellowOnTime
digitalWrite(yellowLEDPin,LOW); //Turn yellow LED off
delay(yellowOffTime); //Leave off for yellowOffTime
}
Serial.println(" ");

The program never stop by the second While, it continus and assume that numYellowBlinks is zero

does anyone have a good answer before i lost my faith in Arduino.

Kent Orthmann

Please post your complete program and follow the advice given in Read this before posting a programming question

As a matter of interest, what have you got the Line ending set to in the Serial monitor ?

I try to learning Arduino
and in a learning video from Poul McWhorter i have this
code :

int redLEDPin=9; //Declare redLEDPin an int, and set to pin 9
int yellowLEDPin=10; //Declare yellowLEDPin an int, and set to pin 10
int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds
int redOffTime=250; //Declare redOffTime an int, and set to 250
int yellowOnTime=250; //Declare yellowOnTime an int, and set to 250
int yellowOffTime=250; //Declare yellowOffTime an int, and set to 250
int numYellowBlinks=5; //Number of times to blink yellow LED
int numRedBlinks=5; //Number of times to blink red LED
String redMessage="The Red LED is Blinking"; //Declaring a String Variable
String yellowMessage="The Yellow LED is Blinking"; //Declaring a String Variable

void setup() {
Serial.begin(230400); // Turn on the Serial Port
pinMode(redLEDPin, OUTPUT); // Tell Arduino that redLEDPin is an output pin
pinMode(yellowLEDPin, OUTPUT); //Tell Arduino that yellowLEDPin is an output pin
}

void loop() {
Serial.println("How Many Times Do You Want the Red LED to blink?"); //Prompt User for Input

while(Serial.available()==0) {}
numRedBlinks=Serial.parseInt(); //Read the data the user has input

Serial.print("antal rød = ");
Serial.println(numRedBlinks);
Serial.println("How Many Times Do You Want the yellow LED to blink?"); //Prompt User for Input

while(Serial.available()==0) {} // Wait for User to Input Data
numYellowBlinks=Serial.parseInt(); //Read the data the user has input

Serial.println(redMessage);
for (int j=1; j<=numRedBlinks; j=j+1) { // Start our for loop
Serial.print(" You are on Blink #: ");
Serial.println(j);
digitalWrite(redLEDPin,HIGH); //Turn red LED on
delay(redOnTime); //Leave on for redOnTime
digitalWrite(redLEDPin,LOW); //Turn red LED off
delay(redOffTime); //Leave off for redOffTim
Serial.println(" ");
Serial.println(yellowMessage);
for (int j=1; j<=numYellowBlinks; j=j+1) { // Start our for loop
Serial.print(" You are on Blink #: ");
Serial.println(j);
digitalWrite(yellowLEDPin,HIGH); //Turn yellow LED on
delay(yellowOnTime); //Leave on for yellowOnTime
digitalWrite(yellowLEDPin,LOW); //Turn yellow LED off
delay(yellowOffTime); //Leave off for yellowOffTime
}
Serial.println(" ");

My serial monitor is at 230400 baud, i have tried 9600 and 115200.

The program never stop by the second While, it continus and assume that numYellowBlinks is zero

does anyone have a good answer before i lost my faith in Arduino.

Kent Orthmann

Report to moderator

Change your serial monitor settings to no line ending.

Or flush the input before you prompt for new input:

  while (Serial.available()) Serial.read();
  Serial.println("How Many Times Do You Want the yellow LED to blink?"); //Prompt User for Input

I've merged your other cross-post @munkemann.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

"report to moderator" is not a REPLY button LOL.