Arduino delay() Blocks All Other Operations
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about Arduino delay() Blocks All Other Operations. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
The Problem
delay() stops the entire program, preventing sensor reads, serial communication, and LED updates.
Quick Fix
Wrong
void loop() {
digitalWrite(13, HIGH);
delay(1000); // Blocks everything for 1 second
digitalWrite(13, LOW);
delay(1000);
}
No serial, no sensors, no button reads during the 2-second loop.
Right
unsigned long prev = 0;
const int interval = 1000;
bool ledState = false;
void loop() {
unsigned long now = millis();
if (now - prev >= interval) {
prev = now;
ledState = !ledState;
digitalWrite(13, ledState);
}
// Other tasks run continuously
checkSerial();
readSensors();
}
LED blinks while serial and sensors run continuously.
Prevention
Replace delay() with millis() timing for all non-blocking applications. Use delay() only for short pauses (<10 ms) or in setup(). For delays in library code, document that it blocks. BlinkWithoutDelay is the canonical example pattern.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
← Previous
Arduino Alternative to delay() Not Working
Next →
Arduino Internal Pull-Up Resistor Not Working
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro