Robot Bug Hunt: Debugging

← Free Lesson Plans for Teachers

Free Lesson Plan

Grade 2Engineering & Coding45 minFinch1A-AP-141A-AP-11

⬇ Download PDF (lesson, student sheets & answer key)

Driving question: When a program does not work, how do we find and fix the problem?

Overview

Students get a robot, a floor maze, and programs that are almost right. Each program has one "bug." Students predict what the robot will do, run the program, find the step where the robot went wrong, and fix it.

They learn a simple debugging routine they can use any time: predict, run, find the first wrong step, change one thing, test again.

Standards

CodeStandard
CSTA 1A-AP-14 (2017)finding and fixing program errors
CSTA 1A-AP-11 (2017)breaking a job into steps

CSTA codes are from the 2017 CSTA K-12 Computer Science Standards and show which standards this lesson practices. This lesson has not been reviewed or endorsed by CSTA. CSTA released revised PK-12 standards in 2026.

Learning Objectives

Students will:

  • predict what a program will do before running it.
  • find the first step where a robot's actions do not match the plan.
  • fix one bug at a time and test again.

Materials

Geyer resources for this lesson

Also needed

  • 1 tablet or Chromebook per group with FinchBlox (Level 2 so you can set one move to match one maze square; Level 1 works if each square is 10 cm)
  • Masking tape maze on the floor or on the Finch Math Mat grid (one square = one move; one maze per class or station)
  • Bug cards (on Student Sheet 1), 1 set per group
  • Student Sheet 2, 1 copy per student (below and in the PDF)

Vocabulary

WordWhat it means
bugA mistake in a program.
debugFind and fix a mistake in a program.
predictSay what will happen before it happens.
testRun a program to see if it works.

Safety Notes

  • Run Finch robots on the floor or inside a boxed-in area such as the Finch Arena or a taped zone. A Finch can drive off a table edge.
  • Keep walkways clear of robots and charging cables while students move around the room.
  • Choking hazard: the micro:bit and cable ends are small. An adult handles cables and charging.

Before You Teach

  • Tape a maze that matches the Student Sheet 1 drawing (6 squares wide, 4 tall).
  • Set one move block to equal one maze square (in FinchBlox Level 2, set the distance and test; in Level 1, make each square 10 cm).
  • Load or write out the three buggy programs on cards.

Warm-Up (5 min)

  • Give the class a buggy dance: "Clap, clap, stomp, clap." Do it wrong on purpose. Ask: "Which step was wrong?"

Procedure

Model the routine (8 min)

  1. Post the steps: 1. Predict. 2. Run. 3. Find the first wrong step. 4. Change one thing. 5. Test again.
  2. Model with Bug 1 using think-aloud.

Bug hunt (20 min)

  1. Groups run Bugs 2 and 3. A "tracker" points to each block on the screen while the robot moves, so the group sees which block was running when things went wrong.
  2. Record the bug and the fix on Student Sheet 2.

Make a bug (7 min)

  1. Groups write a correct program, then change one block and trade with another group to debug.

Reflect (5 min)

  1. Ask: "Why do we change only one thing at a time?" (So we know what fixed it.)

Differentiation

SupportOn-levelChallenge
• Do Bug 1 together, then Bug 2 with a partner.
• Use arrow cards on the floor next to the maze to act out each step.
• Highlight the turn blocks in a different color.
• Complete the procedure and student sheets as written.• Find a shorter correct path.
• Debug a program with two bugs.
• Write the routine in your own words for a kindergarten buddy.

Assessment

  • Listen for students naming the first wrong step.
  • Check that each fix changes only one block.
  • Watch the tracker job.

Exit ticket: Show: "forward, forward, turn right, forward" when the robot needed to turn left. Ask: "Which block is the bug? How would you fix it?"

CriterionBeginningDevelopingProficient
PredictsNo predictionPartial predictionClear prediction before each run
Finds the bugGuessesFinds it with helpFinds the first wrong step
Fixes and retestsChanges many thingsFixes after several triesChanges one thing and retests

Extensions

  • Keep a class "bug log" poster for all coding lessons.
  • Use the routine to debug a math problem.
  • Try the same maze with the Code & Go Robot Mouse.

Student Sheets

Use these sheets in class, or download the PDF for a print-ready layout.

Student Sheet 1

The Maze and the Buggy Programs

Print-ready version in the PDF.

Name: ______________________________   Date: ______________

HomeStart (facing up)Each square = 1 move. Thick lines are walls.

The robot starts in the bottom-left square, facing up. Each square is 1 move. The goal is to reach Home. Each program below has ONE bug.

ProgramSteps
Bug 1forward 1, turn right, forward 3, turn right, forward 2, turn right, forward 2
Bug 2forward 2, turn right, forward 3, turn left, forward 2, turn right, forward 2
Bug 3forward 1, turn right, forward 3, turn left, forward 2, turn right, forward 1

Student Sheet 2

My Bug Report

Print-ready version in the PDF.

Name: ______________________________   Date: ______________

BugI predicted...The robot went wrong at...My fix
1
2
3

Why should we change only one block at a time?

Show answer key (for teachers)

Answer Key & Teacher Notes

  • Correct program: forward 1, turn right, forward 3, turn left, forward 2, turn right, forward 2 (ends in Home, top-right).
  • Bug 1: the second turn is "turn right," which points the robot down toward the bottom wall. Fix: change it to turn left.
  • Bug 2: "forward 2" puts the robot 3 squares up from the bottom (second row from the top), where wall 1 blocks the move right. Fix: change the first block to forward 1.
  • Bug 3: the last move is "forward 1," which stops one square short of Home. Fix: change it to forward 2.
  • Change one block at a time so you know which change fixed the program.

Teacher notes

Tape a 6-by-4 grid of squares that each match one move. Wall 1 runs from the top edge down 2 squares between columns 2 and 3; wall 2 runs from the bottom edge up 2 squares between columns 4 and 5. Robots may need a little extra turn amount on carpet; adjust once and keep it the same for all groups.

Need a print-ready copy? The PDF includes the lesson, student sheets, and answer key.

Download the PDF  |  All free lesson plans

Free for classroom use. You may print and copy this lesson for your students. © Geyer Instructional Products. Standards text: CSTA K-12 CS Standards © CSTA.