Reading Data FromArduino

Hello guys,

I am new to Arduino and i have recently tried to write a code to read from the serial port. I wrote a code to prompt the user to input data for the number of Red Led Blinks and the number of yellow Led Blinks inside the void loop. However, when I run my code I am able to input data for the red Led and quickly changes back to red led prompt again overlapping the prompt for the Amber

Serial.println("How Many Times Do You Want The Red Led To Be On? ");
while(Serial.available()==0){}
NumOfRedBlink= Serial.parseInt();

Serial.println("How Many Times Do You Want The Yellow Led To Be On? ");
while(Serial.available()==0){}
NumOfYellowBlink= Serial.parseInt();

That is my code

@salimow

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Take a close look at the line-ending setting of the serial monitor.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you post your complete sketch please?
What model Arduino are you using?

Thanks.. Tom... :slight_smile:

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

Getting input from users is actually one of the more complex programming tasks because there are a lot of issues to consider.

...R

TheMemberFormerlyKnownAsAWOL:
Take a close look at the line-ending setting of the serial monitor.

@OP
Look at the following diagram of Fig-1 for Serial Monitor; where, the 'Line ending tab' should be at 'No line ending' option.


Figure-1:

Serial Monitor -- that you are expecting.
smLed.png
Figure-2:

Sketch
Please, post your codes with code tags (</>)

smLed.png

led5.ino (834 Bytes)