const unsigned long event1 = 2000UL;
const unsigned long event2 = 10000UL;
// state:
// 0 = idle, do nothing, there is even no code for that.
// 1 = led is off for 2 seconds, after startup
// 2 = led is on for 8 seconds.
int state = 0;
void setup() {
pinMode(LED_BUILTIN,OUTPUT);
state = 1; // go to first state (wait two seconds with led off)
}
void loop() {
unsigned long currentMillis = millis();
if (state == 1 && currentMillis >= event1) {
digitalWrite(LED_BUILTIN,HIGH);
state = 2; // go to next state (wait 8 seconds with led on)
}
else if (state == 2 && currentMillis >= event2) {
digitalWrite(LED_BUILTIN,LOW);
state = 0; // go to idle state (there is not even code for it)
}
}