Why delay() Blocks Everything
See how pausing stops your board from reacting.
Why delay() Blocks Everything is a free Arduino & IoT Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Easy Pause
The delay function pauses your sketch for a set number of milliseconds. It is the simplest way to slow things down and make a blink visible.
delay(1000);What 1000 Means
delay(1000) waits one full second, since the value is in milliseconds. So delay(500) is half a second and delay(2000) is two seconds.
It Freezes the Board
The catch: delay freezes everything. While it waits, your board does nothing else at all, like a person holding their breath. 😮
Missed Button Presses
During a delay your board cannot notice a button press. Tap it mid-pause and the press is simply ignored, which feels broken to a user.
See the Problem
Here a one-second delay sits between the checks, so any press in that whole second is lost before the next read happens.
digitalRead(buttonPin);
delay(1000);Only One Task at a Time
Because delay blocks, you cannot blink an LED and watch a sensor at the same time. The whole sketch waits as one task.
Stacked Delays Add Up
Two delay calls in a row simply add together. Spread several around and your board spends most of its life frozen and unresponsive.
Fine for Simple Sketches
delay is not evil. For a single blinking LED with nothing else going on, it is perfectly clear and totally fine to use.
The Real Goal
The real goal is a non-blocking sketch that keeps reacting while it also times events. That means never freezing the loop with a long pause.
Think About Time Instead
Instead of pausing, you can ask how much time has passed and act only when enough has gone by. The loop keeps spinning meanwhile.
A Better Tool Is Coming
Soon you will meet millis, a clock that lets you measure elapsed time without freezing. It is how real projects stay responsive.
Quick Check
What is the main drawback of using delay in a sketch?
Recap
You saw that delay is simple but freezes the board, missing inputs and blocking other tasks. Next you will time events without stopping the loop. ✨
Frequently asked questions
Is the “Why delay() Blocks Everything” lesson free?
Yes — the full text of “Why delay() Blocks Everything” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “Why delay() Blocks Everything”?
See how pausing stops your board from reacting. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Why delay() Blocks Everything” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- int, float, bool on Arduino
- Why delay() Blocks Everything
- Blink Without delay Using millis
- Run Two Things at Once