Challenge - 5 Problems
LED Blink Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this LED blink code?
Consider the following Arduino code that blinks an LED connected to pin 13. What will be the LED's behavior?
Arduino
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}Attempts:
2 left
💡 Hint
Look at the delay times and the order of turning the LED on and off.
✗ Incorrect
The code turns the LED on, waits 500 milliseconds, then turns it off and waits another 500 milliseconds. This cycle repeats, causing the LED to blink on and off every half second.
❓ Predict Output
intermediateWhat is the LED blink pattern of this code?
Analyze this Arduino code. What pattern will the LED on pin 13 follow?
Arduino
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(200);
}Attempts:
2 left
💡 Hint
Check the delay times after turning the LED on and off.
✗ Incorrect
The LED is turned on, then the program waits 1000 milliseconds (1 second), then turns off and waits 200 milliseconds before repeating.
🔧 Debug
advancedWhat error does this LED blink code cause?
Look at this Arduino code snippet. What error will occur when compiling or running it?
Arduino
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}Attempts:
2 left
💡 Hint
Check punctuation carefully in the setup function.
✗ Incorrect
The original code was missing a semicolon after pinMode(13, OUTPUT), causing a syntax error. This corrected code includes the semicolon, so it compiles and runs correctly.
❓ Predict Output
advancedWhat is the LED blink pattern of this code with variable delay?
What pattern will the LED on pin 13 follow when running this Arduino code?
Arduino
int delayTime = 200; void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(delayTime); digitalWrite(13, LOW); delay(delayTime * 2); }
Attempts:
2 left
💡 Hint
Look at how delayTime is used for on and off durations.
✗ Incorrect
The LED is on for delayTime (200 ms) and off for delayTime * 2 (400 ms), creating an uneven blink pattern.
❓ Predict Output
expertWhat is the LED blink pattern of this code with nested loops?
Analyze this Arduino code. What is the total number of LED blinks before the pattern repeats?
Arduino
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
for (int i = 0; i < 3; i++) {
digitalWrite(13, HIGH);
delay(300);
digitalWrite(13, LOW);
delay(300);
}
delay(1000);
}Attempts:
2 left
💡 Hint
Count how many times the loop runs and the delays involved.
✗ Incorrect
The for loop runs 3 times, blinking the LED on and off each time with 300 ms delays, then the code waits 1 second before repeating the whole pattern.
