Skip to main content

Command Palette

Search for a command to run...

How to delay in Arduino?

Published
1 min read
How to delay in Arduino?

In Arduino, “delay” usually means one of two things:

1) Simple blocking delay: delay() / delayMicroseconds()

Milliseconds

delay(1000);   // waits 1000 ms = 1 second

Microseconds

delayMicroseconds(200);  // waits 200 µs

Notes

  • delay() blocks: nothing else in loop() runs during that time.

  • delayMicroseconds() is for short delays (timing pulses), not long waits.


Use this when you want to “wait” but still do other work (read sensors, handle buttons, serial, etc.).

const int LED = 13;
unsigned long last = 0;
const unsigned long interval = 1000; // ms

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  unsigned long now = millis();

  if (now - last >= interval) {
    last = now;
    digitalWrite(LED, !digitalRead(LED));
  }

  // other code can run here while waiting
}

Quick rule

  • One simple pause → use delay()

  • Anything interactive / multiple tasks → use millis() timing