-
Notifications
You must be signed in to change notification settings - Fork 0
Debug Detective
Vishwas Parpattegar edited this page Sep 4, 2025
·
2 revisions
Your lab partner wrote some code to make an LED blink every second, but it's not working! Put on your detective hat and find all the bugs to make it work properly.
- Find and fix 4 bugs in the provided Arduino code
- Make an LED blink every second (1 second ON, 1 second OFF)
- Use serial communication to display status messages
- Learn common debugging techniques and Arduino syntax rules
LED should be blinking!
LED should be blinking!
LED should be blinking!
(LED physically blinks ON for 1 second, OFF for 1 second)
Someone left this "working" code, but the LED isn't blinking at all! There are 4 bugs hiding in this code. Can you find and fix them all?
int ledPin = 13;
void setup() {
pinMode(ledPin, INPUT);
serial.begin(9600)
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1);
digitalwrite(12, LOW);
delay(1000);
Serial.println("LED should be blinking!");
}
Click here only if you're really stuck!
-
Bug 1:
pinMode(ledPin, INPUT)
should bepinMode(ledPin, OUTPUT)
-
Bug 2:
serial.begin(9600)
should beSerial.begin(9600);
(capital S + semicolon) -
Bug 3:
delay(1)
should bedelay(1000)
for 1-second timing -
Bug 4:
digitalwrite(12, LOW)
should bedigitalWrite(ledPin, LOW)
(capital W + correct pin)