I am trying to implement a waiting period when the user can input a number via the Serial Monitor but if they don't enter anything within a certain time the script continues using defaults.
I have implemeted the inputs with:
while(Serial.available() == 0);
set = Serial.read();
if (set == '1'){
Do something
}
if (set == '2'){
Do something else
}............
That works just fine. I now need to implement the timer. At first I tried this:
Serial.println("Enter (1), (2), (3) or (4)continue");
unsigned long counter = millis(); // set counter variable
while(Serial.available() == 0);
if(counter > 20000){}
set = Serial.read()........;
But that doesn't work. I tried putting loop() in the if parantheses but that doesn't work either. Finally I tried "while(counter < 20000);" again without success.
What am I missing here?