Wait for an operator input

I am trying to write a sketch which allows an operator to input two values (I'll be using these values later via two EasyDriver stepper drivers to move two stepper motors). I can't work out/find out how to get a sketch to stop looping and wait for an input. It needs to be an input of a number between 1 and 99.

I am quite new to this programming and may be missing something, but I've been through all the tutorials I can find and the Arduino Cookbook and can only find examples of input which are in the main loop. When I use these, it keeps going through the whole loop over and over whilst there's no input. So when I include Serial.print text to ask for an input, it just keeps writing this over and over.

I tried putting the input bit it in a separate function, but when there's no input it keeps returning to the main loop and back again, over and over :~

Any help anyone could give me with this would be greatly appreciated. I just can't think of a way of making it wait for the input.

Thanks :slight_smile:

Look at using Serial.available() to check for user input and have some means of indication to your program that input is complete, often a Carriage Return.

Have a look at the description of Serial.available() in the reference installed with the Arduino IDE, Google for examples of its use or search this forum for a multitude of posts on the subject.

Thank you. Much appreciated. :slight_smile: