What are the practical differences between using delay() versus a while loop with millis() for timing in Arduino projects? I assumed both methods are blocking, but I'm not completely sure.
Example using a while loop:
unsigned long start = millis();
while (millis() - start <= interval) {
DoSomething();
}
Example using delay():
StartSomething();
delay(interval);
StopSomething();
How do these methods compare in terms of blocking behavior, responsiveness, and potential trade-offs?
ifinstead ofwhile