1 · First steps
Blink without delay() (millis)
Advanced20 min
Goal
Replace delay() with a time comparison based on millis().
Why it matters
delay() freezes the whole program. millis() lets you do several things at once.
Steps
- 01Declare unsigned long previous = 0; and const long interval = 1000;
- 02In loop(), compare millis() - previous >= interval.
- 03Toggle the LED state and update previous.
- 04Check that no delay() is left.
This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.