Serial.parseInt() Help

Hi I am having a little issue here that needs some help. I am using Serial.parseInt() to read from the Serial Port.

if (Serial.available() > 0)
{
 int J1step = Serial.parseInt();
 int J2step = Serial.parseInt();
 int J3step = Serial.parseInt();
 int J4step = Serial.parseInt();
}

If I give all the values immediately then it works fine. But if I give just "J1step" value then it waits 5 seconds then just ignores the last three lines and moves on. Is there any way that I can stop it for as long as I want at Serial.parseInt()? I mean it wouldn't move on unless it reads all the values no matter how much time is passed. Thanks a lot!

Is there any way that I can stop it for as long as I want at Serial.parseInt()?

Your approach is backwards. You ought to be thinking, instead, about processing what you get, when you get it, and acting upon the data only when you have enough of it.

You can set the timeout period that parseInt() waits. Set it to two weeks if that makes your heart go pitter patter. But, I wouldn't. I prefer my code to be as fast as possible.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R