Skip to main content

Lesson 10 · Module 2 Final Project

Module 2 · Line Tracking

Lesson 10 · Module 2 Final Project

Multi-dayCapstoneTwo cooperating classes
👩‍🏫

Teacher mode is on. Toggle it off (bottom-right) to preview the student view.

Time to put it all together. Using your LineSensor and LineTrack classes, you'll build a program that follows the taped circle, detects the cross, reverses direction, and repeats — four times — then stops. It's the capstone of everything in Module 2: sensors, control loops, decisions, classes, and composition.

Learning Objectives

By the end of this project you will be able to:

  • Combine multiple classes into one complete, working program
  • Write a short, readable main program that orchestrates class methods
  • Test and debug a real robot behavior systematically
  • Explain and demonstrate your design

The mission

Your robot must:

  1. Follow the taped circle with track_until_cross().
  2. Detect the cross intersection.
  3. Reverse direction.
  4. Keep following, and repeat for 4 total reversals.
  5. Stop and print a completion message.
Option A

Standard

The mission above, using your existing classes unchanged. Focus on a clean main program and solid debugging.

Option B

Enhanced

Add a turn_around() method, time each leg, and flash the LED or beep at every reversal.

Option C

Advanced

Add line-loss recovery, or speed up on later laps. Invent your own twist (teacher-approved).

Activity · Plan before you build

Pseudocode the main program first, in plain English, before you type any Python. It will be shorter than you expect, because the classes do the heavy lifting — each line of your plan is close to one line of code.

Knowledge Check

For the final project, do you need to rewrite the sensor and driving logic from scratch?

Build it in pieces

You have every part already: LineSensor from Lesson 8, LineTrack from Lesson 9, and the reversal trick you worked out above. What's left is assembling them and tuning — which is most of what real robot work is.

Build in this order, testing each before adding the next:

  1. track_until_cross() alone — does it follow the line and stop at the cross?
  2. One turn_right() — does it find the line again?
  3. One full reversal — two right turns, then following back the other way.
  4. The loop that does it four times.

Activity · Test, tune, present

Work up in stages, and keep a note of what you tuned:

  1. Does track_until_cross() follow and stop at the cross?
  2. Does one turn-around find the line again?
  3. Does one full reversal work end to end?
  4. Do all four reversals run and stop?

Then demo it and reflect: what was hardest, how did classes make the project easier, and what would you add with more time?

Knowledge Check

Your robot follows the line but blows past the cross without stopping. What's the best first thing to try?

You built a robot that thinks 🎉

Look back at the journey: you started Module 2 reading a single sensor value, and you're finishing it with two cooperating classes that follow a line, detect intersections, and navigate a course. That LineSensor/LineTrack design — sensing and driving cleanly separated and composed — is exactly how professional robot code is structured, and you'll build directly on it next.

Resources