millis() vs delay(): blink without freezing
delay() stops the whole program; millis() lets the LED blink while the code keeps reading the knob.
Why does your blink code freeze the whole Arduino? ⏱️💡
1️⃣ THE PROBLEM: delay(500) means "stop and wait half a second". While it waits, NOTHING else runs — button presses and knob turns are ignored.
2️⃣ millis(): a clock that counts the milliseconds since the board powered on. Don't wait — just check it: has half a second passed?unsigned long last = 0;if (millis() - last >= 500) { … }
3️⃣ FLIP + NOTE THE TIME: if yes, flip the LED and save the time:last = millis();digitalWrite(13, !digitalRead(13));
The loop never stops, so analogRead(A0) keeps reading your knob — live!
Check the clock, don't wait!
unsigned long last = 0;
if (millis() - last >= 500) { … }
last = millis();
digitalWrite(13, !digitalRead(13));Read the voiceover (transcript)
- Why does your blink code freeze the Arduino?
- Delay means stop and wait. While it waits, buttons and knobs are ignored!
- Millis is a clock, counting milliseconds since power on. Just check it: has half a second passed?
- If yes, flip the LED and note the time. The loop never stops, so the knob still works!
- Check the clock, don't wait!
- Next: two LEDs, two speeds! Follow for part thirteen!
Related lessons
Get new lessons + early access to the full course
One email when new lessons drop. No spam, unsubscribe any time.
✓ You're on the list! We'll email you when new lessons drop.
By joining you agree to the privacy policy.




