Lesson plan

Fix the bug lesson plan

Short puzzles on an Uno: one planted fault each, in the wiring or the code. Find it, fix it, and see it work.

2 chapters, 8 lessons, about 1 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • A missing wire, a missing ground, and a wire on the wrong pin.
  • A copied line, a missing pinMode, an upside-down test, an off-by-one and a stray semicolon.

Materials for the whole unit

  • Arduino Uno R3
  • Full-size breadboard
  • LED
  • Pushbutton
  • Resistor

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 30 min

Wiring faults

A missing wire, a missing ground, and a wire on the wrong pin.

LessonTimeWhat students do
The LED that never lightsBlink is running, pin 13 is switching, and the LED on the breadboard stays dark. Find the gap in the loop.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The board with no groundPin 13 is high, the LED and resistor are wired to the rail, and nothing lights. Find what the loop is missing.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The button on the wrong pinThe sketch reads a button on pin 2 and lights the LED. Hold the button and nothing happens. Find out why.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was

Materials

  • Arduino Uno R3
  • Full-size breadboard
  • LED
  • Pushbutton
  • Resistor

Check for understanding

Each student finishes "The button on the wrong pin" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What it was".

Chapter 2. About 50 min

Code faults

A copied line, a missing pinMode, an upside-down test, an off-by-one and a stray semicolon.

LessonTimeWhat students do
The blink that stays onA blink sketch with two writes and two delays, and an LED that comes on and never goes off. Read the loop.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The output that is not an outputdigitalWrite says HIGH and the LED barely glows. The loop is fine. Find what setup() leaves out.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The lamp that is on until you pressThe LED should light while the button is held. It is lit with the button up and goes dark when you press.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The count that stops at nineA for loop that should print 1 to 10 prints 1 to 9 and says done. Find where ten went.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was
The if that always runsThe LED should light only while the button is held, and it is on all the time. One character is to blame.10 min
  1. The complaint
  2. Find it
  3. Fix it
  4. What it was

Materials

  • Arduino Uno R3
  • Full-size breadboard
  • LED
  • Pushbutton
  • Resistor

Check for understanding

Each student finishes "The if that always runs" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What it was".

Your class

Teach this unit as a class

Start a class from this course and its 8 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.