Arduino Maze Solving Wall Follower Robot
Level 26 · Level 26 — Hand On The Wall · 50 minutes
Twenty rooms, one way out, and a rule you could write on your hand: never let go of the wall on your left.

Preview the project free; a course seat is required to run and submit. No hardware kit needed.
Your project challenge
Get the robot out of the maze. Keep its LEFT hand on the wall. Wire it up: - All three sonars: VCC to 5V, GND to GND - Front: TRIG to D5, ECHO to D4 - Left: TRIG to D3, ECHO to D2 — aimed straight out to the side - Right: TRIG to D12, ECHO to D13 Left open, turn left. Else drive on. Else turn right. Else turn all the way round.
Components you’ll use
- Arduino Uno
- L298N Motor Driver
- DC Gear Motor × 2
- Battery
- HC-SR04 Ultrasonic Distance Sensor × 3
What you’ll build
A robot that finds its way out of a maze it has never seen. No map, no memory.
How it works
- Three sonars: forward, straight out to the left, straight out to the right.
- A corridor is
600 mmwide, so a centred robot reads30 cmto each side wall and23 cmto a wall dead ahead. - A gap reads
90 cmor more. Nothing ever reads in between. - To the side, anything over 55 cm is a way through.
The key idea
This is not a search. It is a rule.
Left open? Turn left. Otherwise straight on. Otherwise right. Otherwise turn all the way round.
Every wall here is joined to every other wall. So the wall is one piece, and walking with a hand on one piece traces the whole of its edge — which every room, and the way out, touches.
⚠ Watch out
The rule walks you into exactly one dead end, and that is where most robots die. “Turn towards whichever side has more room” works in a corridor. In a dead end both sides are walls, so the robot picks one at random, comes back out holding the other wall, and wanders until the clock stops. Turn a full 180 instead.
The interactive editor includes the wiring guide, code editor and simulation controls.