Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
LED Blink Pattern
📖 Scenario: You have a small LED connected to your Arduino board. You want to make it blink in a simple pattern to test your setup.
🎯 Goal: Create a program that makes the LED blink on and off repeatedly with a clear pattern.
📋 What You'll Learn
Use the built-in LED on pin 13
Turn the LED on and off with a delay
Use variables to control the delay time
Print messages to the Serial Monitor when the LED turns on and off
💡 Why This Matters
🌍 Real World
Blinking LEDs are used in many devices to show status, alerts, or activity.
💼 Career
Understanding how to control hardware like LEDs is a basic skill for embedded systems and electronics jobs.
Progress0 / 4 steps
1
Setup LED pin
Create a variable called ledPin and set it to 13. In the setup() function, set the ledPin as an output using pinMode. Also, start the serial communication at 9600 baud using Serial.begin(9600).
Arduino
Hint
Use pinMode(ledPin, OUTPUT); inside setup() to set the LED pin as output.
Use Serial.begin(9600); to start serial communication.
2
Add delay time variable
Create an integer variable called delayTime and set it to 500. This will control how long the LED stays on or off in milliseconds.
Arduino
Hint
Declare int delayTime = 500; outside the functions so it can be used everywhere.
3
Write LED blink logic
In the loop() function, turn the LED on using digitalWrite(ledPin, HIGH), print "LED ON" to the Serial Monitor, then wait for delayTime milliseconds using delay(delayTime). Next, turn the LED off using digitalWrite(ledPin, LOW), print "LED OFF" to the Serial Monitor, and wait again for delayTime milliseconds.
Arduino
Hint
Use digitalWrite to turn the LED on and off.
Use Serial.println to print messages.
Use delay(delayTime) to pause.
4
Display the blink pattern
Upload the program and observe the Serial Monitor. The output should show alternating lines of LED ON and LED OFF every 500 milliseconds.
Arduino
Hint
Open the Serial Monitor in the Arduino IDE to see the blinking messages.
Practice
(1/5)
1. What does the delay(1000); command do in an Arduino LED blink program?
easy
A. Pauses the program for 1000 milliseconds (1 second)
B. Turns the LED on for 1000 milliseconds
C. Turns the LED off for 1000 milliseconds
D. Sets the LED brightness to 1000
Solution
Step 1: Understand the delay function
The delay() function pauses the program for the given time in milliseconds.
Step 2: Interpret the argument 1000
1000 milliseconds equals 1 second, so the program waits for 1 second before continuing.
Final Answer:
Pauses the program for 1000 milliseconds (1 second) -> Option A
Quick Check:
delay(1000) = 1 second pause [OK]
Hint: delay(ms) pauses program for ms milliseconds [OK]
Common Mistakes:
Thinking delay turns LED on or off
Confusing delay time with brightness
Assuming delay is in seconds
2. Which of the following is the correct syntax to set pin 13 as an output in Arduino?
easy
A. pinMode(OUTPUT, 13);
B. pinMode(13, OUTPUT);
C. digitalWrite(13, OUTPUT);
D. digitalWrite(OUTPUT, 13);
Solution
Step 1: Recall pinMode syntax
The correct syntax is pinMode(pin, mode); where pin is the pin number and mode is INPUT or OUTPUT.
Step 2: Match the correct order
pinMode(13, OUTPUT); uses pinMode(13, OUTPUT); which matches the correct order and parameters.
Final Answer:
pinMode(13, OUTPUT); -> Option B
Quick Check:
pinMode(pin, OUTPUT) sets pin as output [OK]
Hint: pinMode(pin, OUTPUT) sets pin as output [OK]
Common Mistakes:
Swapping pin and mode parameters
Using digitalWrite instead of pinMode to set mode
Missing semicolon at end
3. What will be the output of this Arduino code snippet?
D. digitalWrite(13, HIGH); delay(500); digitalWrite(13, LOW); delay(500); delay(2000);
Solution
Step 1: Understand the blink pattern
The LED should blink twice quickly (short on/off), then pause 2 seconds before repeating.
Step 2: Analyze each option's timing
for(int i=0; i<2; i++) { digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); } delay(2000); blinks twice with 200 ms on and off delays, then pauses 2000 ms. This matches the pattern.
Step 3: Check other options
digitalWrite(13, HIGH); delay(200); digitalWrite(13, LOW); delay(200); delay(2000); blinks once only. for(int i=0; i<2; i++) { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } delay(2000); blinks twice but with 1 second delays (too slow). digitalWrite(13, HIGH); delay(500); digitalWrite(13, LOW); delay(500); delay(2000); blinks once with 500 ms delays.