Introduction
The delay() function pauses the program for a set time. It helps control timing in your Arduino projects.
Jump into concepts and practice - no test required
The delay() function pauses the program for a set time. It helps control timing in your Arduino projects.
delay(milliseconds);
milliseconds is the time to pause, in thousandths of a second.
During delay(), the Arduino does nothing else.
delay(1000);delay(500);delay(2000);This program blinks the built-in LED on and off every second using delay().
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn LED on
delay(1000); // wait 1 second
digitalWrite(LED_BUILTIN, LOW); // turn LED off
delay(1000); // wait 1 second
}While delay() runs, the Arduino cannot do other tasks.
For multitasking, consider using millis() instead of delay().
delay() pauses the program for a set time in milliseconds.
It is simple to use but stops all other actions during the pause.
Great for basic timing like blinking LEDs or waiting between steps.
delay(1000); function do in an Arduino program?void setup() {
Serial.begin(9600);
Serial.println("Start");
delay(2000);
Serial.println("End");
}
void loop() {}void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000)
digitalWrite(13, LOW);
delay(1000);
}delay() to do this?