flashing means
at timepoint 1 switch LED on
at timepoint 2 switch LED off
repeat
or with example-timestamps
0:00 switch LED on
0:02 switch LED off
0:04 switch LED on
0:06 switch LED off
the switch on / switch off has to be repeated.
With non-blocking timing the repeating is done by
void loop()
no other loops required there are even no other loops allowed
because these other loops would have the same effect as delay() = blocking code-execution
So as pseudo-code blinking an LED looks like this
void loop()
if (someTimeHasPassedBy) {
// change LED-state
if (LED_IS_switched_On) {
switchLedOff();
}
if (LED_IS_switched_Off) {
switchLedOn();
}
}
}
a better structured version of this code is to declare a function named changeLED_State()
void changeLED_State() {
if (LED_IS_switched_On) {
switchLedOff();
}
if (LED_IS_switched_Off) {
switchLedOn();
}
}
void loop() {
if (someTimeHasPassedBy) {
changeLED_State();
}
}
the name of the function is self-explaining. No additional comment needed
Doing even more advanced things like
wait for a button-press before any blinking starts
start blinking a second led after same time has passed by since the first LED started blinking
is best coded using a state-machine.
This kind of functionality is medium advanced and you need a medium amount of code to make this work which means a medium amount of things to learn new.
best regards Stefan