Introduction
We use LED blink patterns to show simple signals or messages with lights. It helps us learn how to control hardware step by step.
Jump into concepts and practice - no test required
We use LED blink patterns to show simple signals or messages with lights. It helps us learn how to control hardware step by step.
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
}pinMode sets the LED pin as output so we can control it.
digitalWrite turns the LED on or off.
digitalWrite(LED_BUILTIN, HIGH); // LED on
delay(500); // wait half a second
digitalWrite(LED_BUILTIN, LOW); // LED off
for (int i = 0; i < 3; i++) { digitalWrite(LED_BUILTIN, HIGH); delay(300); digitalWrite(LED_BUILTIN, LOW); delay(300); }
This program makes the LED blink three times quickly, then waits for one second before repeating the pattern.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Blink pattern: 3 quick blinks, then pause
for (int i = 0; i < 3; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
digitalWrite(LED_BUILTIN, LOW);
delay(200);
}
delay(1000); // pause before repeating
}Use delay() to control how long the LED stays on or off.
LED_BUILTIN is the built-in LED on most Arduino boards, usually on pin 13.
Changing the delay times changes the blink speed and pattern.
LED blink patterns help us communicate simple signals with light.
Use digitalWrite and delay to create blink effects.
Loops let us repeat blink sequences easily.
delay(1000); command do in an Arduino LED blink program?delay() function pauses the program for the given time in milliseconds.pinMode(pin, mode); where pin is the pin number and mode is INPUT or OUTPUT.pinMode(13, OUTPUT); which matches the correct order and parameters.void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000)
digitalWrite(13, LOW);
delay(1000);
}delay(1000) is missing a semicolon at the end, causing a syntax error.