LED Series Part 14 = Arduino C++ L11: add a button without freezing
delay() freezes the board so a press is missed; with millis() the loop never waits, so read the button (INPUT_PULLUP: pressed = LOW) on every pass while the LED keeps blinking.
Your LED blinks… then you add a button and it ignores you? Here's the fix! 🔴🟢
❌ With delay(500) the board just waits — a press during the wait is never read.
✅ With millis() the loop never waits: it spins thousands of times a second.
🔁 So read the button every time around the loop with digitalRead(2).
🧲 With INPUT_PULLUP, pin 2 sits HIGH — pressing the button joins it to GND, so pressed = LOW!
🎉 The blink keeps going AND the button answers instantly.
Read the voiceover (transcript)
- Your LED blinks. Add a button: ignored?
- With delay, the board just waits. Your press is missed!
- With millis, the loop spins thousands of times a second.
- So check the button every time around the loop.
- Pressed: what does pin two read?
- Low! The pull-up flips it.
- Blink keeps going, the button answers!
- Next: one press, five clicks? Follow for Part 15!
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.




