Skip to content

Debug Detective

Vishwas Parpattegar edited this page Sep 4, 2025 · 2 revisions

Debug Detective Quest - Fix the Broken Code! 🔍

Objective

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.

Requirements

  • 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

Expected Output

LED should be blinking!
LED should be blinking!
LED should be blinking!
(LED physically blinks ON for 1 second, OFF for 1 second)

The Broken Code

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!");
}

The Bugs

Click here only if you're really stuck!
  1. Bug 1: pinMode(ledPin, INPUT) should be pinMode(ledPin, OUTPUT)
  2. Bug 2: serial.begin(9600) should be Serial.begin(9600); (capital S + semicolon)
  3. Bug 3: delay(1) should be delay(1000) for 1-second timing
  4. Bug 4: digitalwrite(12, LOW) should be digitalWrite(ledPin, LOW) (capital W + correct pin)
Clone this wiki locally