Challenge - 5 Problems
Arduino Loop Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this Arduino sketch?
Consider the following Arduino code. What will be printed to the Serial Monitor after the board resets and runs this code?
Arduino
void setup() {
Serial.begin(9600);
Serial.println("Start");
}
void loop() {
Serial.println("Looping");
delay(1000);
}Attempts:
2 left
💡 Hint
Remember that setup() runs once and loop() runs repeatedly.
✗ Incorrect
The setup() function runs once when the Arduino starts, printing "Start". Then loop() runs repeatedly, printing "Looping" every second.
🧠 Conceptual
intermediateHow many times does setup() run in an Arduino program?
In an Arduino sketch, how many times is the setup() function executed during normal operation?
Attempts:
2 left
💡 Hint
Think about what happens when you reset the Arduino.
✗ Incorrect
setup() runs only once at the start after power on or reset. loop() runs repeatedly after that.
🔧 Debug
advancedWhy does this Arduino code print "Start" repeatedly?
This code prints "Start" repeatedly every second instead of just once. What is the cause?
Arduino
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Start");
delay(1000);
}Attempts:
2 left
💡 Hint
Check where the print statement is placed.
✗ Incorrect
The print statement is inside loop(), which runs repeatedly, so "Start" prints every second.
📝 Syntax
advancedWhich option causes a compilation error in Arduino?
Which of the following Arduino sketches will NOT compile?
Attempts:
2 left
💡 Hint
Remember the return type of loop() is void.
✗ Incorrect
loop() is declared void and cannot return a value. 'return 0;' causes a compilation error.
🚀 Application
expertHow many times will the LED blink in this Arduino sketch?
Given this Arduino code, how many times will the LED connected to pin 13 blink after the board resets?
Arduino
int count = 0; void setup() { pinMode(13, OUTPUT); } void loop() { if (count < 3) { digitalWrite(13, HIGH); delay(500); digitalWrite(13, LOW); delay(500); count++; } }
Attempts:
2 left
💡 Hint
Look at how the count variable controls blinking.
✗ Incorrect
The LED blinks while count is less than 3. After 3 blinks, loop() does nothing but runs endlessly.
