Receive int through serial

Hi. I need to receive integers one by one through Serial. I have this code but it has about a second of delay

from send to receive...

What alternative there is?

void setup()

{

Serial.begin(9600);

}

void loop()

{



while (Serial.available() == 0);

int val = Serial.parseInt(); //read int or parseFloat for ..float...

Serial.println(val);

}

The serial input basics tutorial may be of interest.

The default timeout for parseInt() is one second. The serial input basics tutorial reads data as it comes in. No waiting.