Read from serial monitor till timeout
Use this:

byte x;
if (Serial.available() &gt; 0) {
  x = Serial.read();
  }


This doesn't block, because you only read when there is something available in the input buffer.

Now, if you want to read an integer with time-out the serial input, this is a short demo:

#define TIME_OUT 10000L
void setup()
{
    Serial.begin(9600);

    while(!Serial);

    Serial.println();

    Serial.println("Input an int (waiting for 60 seconds");
}

void loop()
{
    static unsigned long timeLastInput = 0;
    unsigned long now = millis();
    static char buffer[10];
    static int index = 0;
    int value;

    if(Serial.available() &gt; 0) {
        char x = Serial.read();
        timeLastInput = now;

        if(isDigit(x)) {
            buffer[index++] = x;
        } else {
            if(index &gt; 0) {
                buffer[index] = 0;
                value = atoi(buffer);
                Serial.print("Integer=");
                Serial.println(value);
                index = 0;
            }
        }
    }

    if(now - timeLastInput &gt; TIME_OUT) {
        Serial.println("Time out");
        index = 0;
        timeLastInput = now;
    }
}


It works by reading all digits into buffer. A non digit input signal the end of the integer. We use atoi to convert the integer ascii representation in his binary value. The result you wants is stored in the value variable.

Note that we read only one char at the time in each loop pass.

And this how the output looks:



And remember: code doesn't manage any error condition; is up to you.