Challenge - 5 Problems
LED Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output pattern of the LED after running this code?
Consider an embedded system where an LED is toggled every 500ms inside a loop. What pattern will the LED show?
Embedded C
void main() {
while(1) {
toggleLED(); // toggles LED state
delay(500); // delay 500 milliseconds
}
}Attempts:
2 left
💡 Hint
Think about what toggle means and the delay duration.
✗ Incorrect
The toggleLED() function changes the LED state from ON to OFF or OFF to ON each time it is called. Since it is called every 500ms, the LED changes state every 500ms, resulting in a blink every 500ms.
🧠 Conceptual
intermediate1:30remaining
Why use LED blinking patterns for debugging in embedded systems?
Which of the following is the main reason developers use LED blinking patterns for debugging embedded systems?
Attempts:
2 left
💡 Hint
Think about what is available when debugging embedded devices without screens.
✗ Incorrect
LED blinking patterns provide a simple way to show system status or error codes visually when no screen or debugger is available.
❓ Predict Output
advanced2:00remaining
What is the LED output after running this code snippet?
This code uses a pattern to blink an LED twice quickly, then pause. What is the LED behavior?
Embedded C
void main() {
while(1) {
turnLEDOn();
delay(200);
turnLEDOff();
delay(200);
turnLEDOn();
delay(200);
turnLEDOff();
delay(1000);
}
}Attempts:
2 left
💡 Hint
Count the ON and OFF durations and the pause.
✗ Incorrect
The LED turns ON for 200ms, OFF for 200ms, ON for 200ms, then OFF for 1000ms, creating two quick blinks followed by a longer pause.
🔧 Debug
advanced1:30remaining
What error does this LED blinking code cause?
This code is intended to blink an LED every second, but it does not work as expected. What error does it cause?
Embedded C
void main() {
while(1) {
turnLEDOn();
delay(1000);
turnLEDOff();
delay(1000);
}
}Attempts:
2 left
💡 Hint
Check punctuation carefully in C code.
✗ Incorrect
The missing semicolon after delay(1000) causes a syntax error, preventing compilation.
🚀 Application
expert2:30remaining
How many unique LED blink states are shown by this code?
This code uses a 3-LED array to indicate system status by turning LEDs ON or OFF in a pattern. How many unique LED ON/OFF states does it produce in one full cycle?
Embedded C
void main() {
int states[4][3] = {
{1,0,0},
{0,1,0},
{0,0,1},
{1,1,1}
};
int i = 0;
while(1) {
setLEDs(states[i][0], states[i][1], states[i][2]);
delay(500);
i = (i + 1) % 4;
}
}Attempts:
2 left
💡 Hint
Count the number of different LED ON/OFF combinations used.
✗ Incorrect
The code cycles through 4 different LED states defined in the states array, so there are 4 unique states.