Print

Activity

Follow the Wall

Write a program to follow any wall or solve a maze!

Free Teacher Materials

Get Access

MATERIALS

This algorithm can also be used to solve a maze by following one wall of the maze. You can set up a maze out of cardboard boxes or have students build their own mazes.

INTERMEDIATE: Add Sensors

Required lessons: Sensor Overview, Conditional Statements

To follow a wall, your robot should repeat these three steps:

  • Move forward in a curved path (left or right) until an obstacle is detected.
  • Move straight back a short distance.
  • Rotate in the opposite direction (45° to 90°).

This is a basic algorithm for following a wall, but you have some work to do to turn this algorithm into a program that works well for your robot. You will need to adjust your speed and other parameters until your program works correctly.

Can your program follow any wall? What happens if it encounters an obstacle along the wall?