I already made the change, but the error is still there, on line 8:
Here is the code:
unsigned long timeout_start;
unsigned long timeout_ms;
#define TIMEOUT_2000MS 2000
#define ERROR_TIMEOUT 1
#define TIMEOUT_START { timeout_start = millis(); }
#define TIMEOUT_CHECK {
if ( (millis() - timeout_start) > timeout_ms )
return ERROR_TIMEOUT;
}
void setup() {
Serial.begin(115200);
timeout_ms = TIMEOUT_2000MS;
TIMEOUT_START
while (!Serial.available() && TIMEOUT_CHECK) {
delay(1);
}
}
void loop() {
}
Here is the error message:
sketch_nov04a:8:1: error: expected unqualified-id before 'if'
if ( (millis() - timeout_start) > timeout_ms )
sketch_nov04a:10:1: error: expected declaration before '}' token
}
exit status 1
expected unqualified-id before 'if'