LED Series Part 13 / Arduino C++ L10: Two LEDs, two speeds — multitasking with millis()
// WHAT YOU WILL LEARN
Give each LED its own 'last' time and interval, so two LEDs blink at different speeds at the same time.
// LESSON NOTES
Two LEDs. Two speeds. One Arduino. ⏱️🔴🟢
❌ delay() freezes the WHOLE loop — both LEDs wait.
✅ Give each LED its own clock with millis():if (now − lastR >= 500) → flip the red LEDif (now − lastG >= 200) → flip the green LED
The loop never waits, so both blink at their own speed — real multitasking on one chip! (Full code in the comments.)
Read the voiceover (transcript)
- Two LEDs, two different speeds. Can you do it?
- With delay, the whole loop freezes, so both LEDs wait.
- The trick: give each LED its own clock with millis!
- Red asks: have five hundred milliseconds passed? Then flip!
- Green asks the same, every two hundred.
- The loop never waits!
- Real multitasking on one chip!
- Next: add a button, no freezing! Follow for Part fourteen!
Related lessons
// NEWSLETTER · FREE
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.




