Code only works when serial monitor is open !

bidouilleelec:
Hello psmelakt

"now the code works." : sure, one day or another you will have millis() >= 30000.

Crap. This is in setup, millis starts with zero and counts up, so "one day or another" happens after 30 seconds.

bidouilleelec:
Have you read post #6 ?

which is

Danois90:
You are calling "while(!Serial);" before "Serial.begin()" - that may be an issue.

Why should anyone read that irrelevant superstitious post anyway?