Build a Line Maze Solver Robot With LSRB Route Memory
A robot that explores a taped line maze on its own, remembers every junction it met, and then runs the shortest route from start to finish without one wrong turn.
A line follower follows. A line maze solver decides. That is the whole jump this project makes, and it is a bigger one than it looks: the robot stops being a control loop with wheels and becomes something that explores an environment it has never seen, remembers what it found, and acts on that memory.
The trick is that none of it replaces the line follower—it sits on top of one. Underneath, the same reflectance array and the same PID loop keep the robot centred on the tape, knowing nothing about mazes. Above it, a thin decision layer watches for the moments when the line branches, classifies what kind of junction it hit, picks a direction, and writes down one character. That separation is what makes the project tractable, and it is the same two-layer split real robots use everywhere.
So the build order matters more than usual. You get plain line following genuinely stable first—tuned in the simulator, then on a large oval of real tape—and only then add junctions. Skip that discipline and every mechanical problem, every calibration drift, every wheel that is 2 mm out of alignment will show up disguised as a maze-solving bug.
Follow the tech tree below top to bottom. Each node opens once its prerequisites are done, and your progress is saved on this device, so you can build the robot over a weekend without losing your place.
Project roadmap
The build path
Follow the tech tree from parts to a robot that follows a taped line. Each node unlocks when its prerequisites are done, and your progress saves on this device.
0 / 21 done
Components
- ControllerArduino UnoThe forgiving 8-bit board most people meet robotics through.
- SensorIR Reflectance Sensor ArrayA row of infrared eyes that tells a robot where the line is.
- DriverTB6612FNG Motor DriverA MOSFET H-bridge that keeps the volts you actually paid for.
- ActuatorDC Gearmotor (TT Motor)The yellow gearbox motor that turns a bare chassis into a moving robot car.
- Chassis2WD Robot ChassisThe deck two motors, a free caster, and your electronics all bolt onto.
- PowerRobot Battery & Power PackThe difference between a robot that runs and one that keeps resetting.
Tutorials in this path
- Beginner · 20 min readBuild a Line Follower Robot: Sensors to PID SteeringFrom IR reflectance sensors to a weighted error to smooth PID steering—how a line follower actually works.
- Beginner · 20 minRead an IR Reflectance Sensor Array for Line FollowingTurn a row of IR sensors into a single, smooth line position you can steer on.
- Beginner · 18 min readHow to Tune a PID Controller: A Practical GuideA hands-on order for tuning P, I, and D gains without the guesswork—and how to try each step live.
- Intermediate · 14 min readDetecting Line Maze Junctions With an IR ArrayClassify T, cross, left, right, dead end and finish from a reflectance array, and resolve the ambiguous cases.
- Intermediate · 15 min readLSRB Path Simplification for Line Maze RobotsRecord turns as L, S, R and B, then collapse every dead-end detour into the optimal route.
Practise before you wire
Tune it in the live simulator
The build path routes through a browser lab. Find gains that follow the track cleanly here, then transfer them to the real robot.
Frequently asked questions
How do you make a maze solving robot with Arduino?
Start with a working line follower: a reflectance array, a PID loop, and a motor driver. Then add a decision layer on top that notices junctions, picks a branch by the left-hand rule, and records each turn as one of four characters—L, S, R or B. When the robot reaches the finish, substitution rules collapse every dead-end detour out of that string, and the second run follows the simplified route. This build path walks the whole chain, and you tune the following layer in a browser simulator first.
What is the LSRB algorithm in a line follower?
LSRB stands for Left, Straight, Right, Back—the four things a robot can do at a junction. The robot records one character per junction during exploration, and every B marks a dead end it had to reverse out of. Six substitution rules replace each three-character window centred on a B with the single turn that would have had the same effect, which removes the detour entirely. Repeat until no B remains and you have the shortest route.
What is the difference between a line maze and a walled maze?
A line maze is black tape on a light board, sensed with a downward-facing reflectance array; a walled maze—the Micromouse format—has physical walls sensed with distance sensors. The sensing is completely different, but the layer above it is the same: explore to build knowledge, then run the best route. A line maze is far cheaper to build, which is why school and college competitions usually use one.
Do I need to buy parts before starting this project?
No. The line-following layer, its PID gains, and the explore-then-optimise behaviour all run in the browser simulators, so you can understand the whole robot before spending anything. Only the last four steps—wiring, calibration, the exploration pass, and the replay—need the physical Arduino, sensor array, driver, motors, chassis, and battery.
Why does my maze robot turn at the wrong junctions?
Almost always because it decides too early. The instantaneous sensor pattern cannot tell a T junction from a crossroads—both read as black right across the array. The robot has to record which branches appeared, drive forward about one robot length, and read again to find out whether the line also continued straight. Deciding on the first reading is the single most common cause of confident wrong turns.
Does LSRB work on any maze?
Only on a perfect maze—one with no loops, where exactly one path connects any two points. Taped line mazes almost always are. If the maze contains a cycle, the left-hand rule can circle forever and there is no dead end for the rules to collapse; at that point you need a real map and a graph search such as flood fill instead.