Skip to main content

Lesson 1 · Introduction to the Grid

Module 3 · Grid Driving

Lesson 1 · Introduction to the Grid

40–50 minCode reuseFrom circle to grid
👩‍🏫

Teacher mode is on — the gray boxes are yours only. Flip the switch (bottom-right) to preview the student view.

You spent Module 2 teaching the robot to follow a line and detect a cross. Now you'll put a whole grid of lines on the floor — and here's the good part: your LineTrack class already knows how to drive it. No new code needed.

Learning Objectives

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

  • Describe how a grid is built from lines and intersections
  • Explain how a grid intersection is just the "cross" from Module 2
  • Use LineTrack.track_until_cross() to drive to the next intersection
  • Place the robot on the grid and reach the first intersection

A grid is just a lot of intersections

A grid is a set of taped lines running two directions — rows and columns. Wherever two lines cross is an intersection, and to the robot's two sensors an intersection looks exactly like the taped cross from Module 2: both sensors go high at once.

🖼️
Diagram — a 3×3 taped grid with intersections circled, robot on a line between two of them
Add a src to drop in your image
Rows and columns of tape. Every place they cross is an intersection — a spot the robot can stop and turn.

That's the whole insight: you already built everything needed to drive a grid. Your LineTrack class has the three methods that do it all:

  • track_until_cross() — follow the line to the next intersection and stop.
  • turn_right() — turn onto the perpendicular line to the right.
  • turn_left() — turn onto the perpendicular line to the left.
Knowledge Check

Do you need to change your LineTrack class to drive on the grid?

Drive to the first intersection

The program is the same LineSensor + LineTrack from Module 2, with a one-line main program:

board = Board.get_default_board()
tracker = LineTrack()

board.wait_for_button()
print("Driving to the first intersection...")
tracker.track_until_cross()
print("Intersection reached!")

Place the robot centered on a line, facing toward the next intersection, and it follows the line right up to the cross and stops.

Knowledge Check

Which LineTrack method drives the robot from where it is to the next intersection?

Activity · Reach it, then turn

Once you're at an intersection you can turn onto the crossing line:

tracker.track_until_cross()
print("Turning right...")
tracker.turn_right()
print("Now facing a new direction!")

Try it from a few starting spots. One thing to watch: if the robot detects an intersection immediately, it started sitting right on one — nudge it back onto the line first.

Knowledge Check

You run the program and the robot reports 'Intersection reached!' instantly without moving. Why?

Real-world connections

Navigating a grid of intersections is how a lot of real automation gets around:

Warehouses

Fulfillment robots

Warehouse robots roll along floor grids, stopping at labeled intersections to pick shelves.

Cities

Street navigation

Self-driving cars think in intersections and blocks — drive to the next junction, then decide.

Games

Grid worlds

Countless games move characters on a grid, one tile at a time, exactly like this.

Wrap-up

  • What is a grid intersection, to the robot? (The same both-sensors-high "cross" from Module 2.)
  • Which method drives one segment to the next intersection? (track_until_cross().)
  • Why didn't you have to write any new class code? (LineTrack already handles lines and crosses — reuse.)

Resources