Skip to content
RoboLearn
Not completed

Maze-solving robot

What you’ll build

A robot that drives through a maze made of walls (cardboard boxes or planks), following the right-hand wall until it reaches the exit.

Parts

Your 2WD car, with two distance sensors: one facing forward and one facing right. Two HC-SR04s work (trigger them one after the other so they don’t hear each other’s echoes), or small ToF sensors such as the VL53L0X.

Build a test maze

  • Corridors at least 2–3 times the robot’s width.
  • Walls at least as high as the sensors.
  • Start simple: an L-shape, then a U-turn, then add dead ends.

The algorithm

The right-hand rule (see Navigation):

Front Right Action
Blocked — Turn left (on the spot)
Clear Gap (far) Turn right gently
Clear Too close Steer left a little
Clear Good distance Straight

Tuning tips

  • Turn into gaps gently, or the robot clips the end of the wall.
  • Slow down: maze solving rewards reliability, not speed.
  • A wall at a slant confuses ultrasonic sensors; keep walls square to the robot’s path.

Finished this lesson?