Why Should I Avoid delay()?

delay pauses your entire program. While it waits, your board cannot read inputs or respond to changes.

What delay really does

  • Stops the loop from running.
  • Misses button presses and sensor events.
  • Makes multiple actions feel slow or unresponsive.

What to use instead

Use millis to check time without blocking:

millis_timing.ino
cpp
unsigned long last = 0;
void loop() {
  if (millis() - last >= 1000) {
    last = millis();
    // do timed action
  }
}
Bottom line

delay is fine for quick tests, but millis is better for real projects.

Related: How do I blink without delay? · How do I do multiple things at once? · How do I make a timer?