What it shows
A robot that always keeps a wall on its left will find the exit of a simply connected maze. It needs three distance readings and a small decision program, which shows how robots navigate.
The science
Left-wall following is a classic algorithm: if there is an opening to the left, turn left; else if the way ahead is clear, go straight; else if the right is open, turn right; otherwise turn around. Three sensors, left, front and right, give distances; a wall is a reading below about 15 cm. A proportional correction keeps the robot about 8 cm from the left wall by speeding one wheel and slowing the other.
Materials
Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- An Arduino Uno or Nano
- Three HC-SR04 ultrasonic sensors
- An L298N motor driver
- A 2WD robot chassis with two gear motors and a castor wheel
- A 7.4 V battery pack (two 18650 cells) and a switch
- Cardboard strips 15 cm high to build a maze 1 m x 1 m
- Jumper wires and double-sided tape
Safety
For this project: Handle lithium cells with care and charge them only with a proper charger under adult supervision. Keep fingers off the wheels. Do not leave the robot running unattended.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Fix the three sensors at the front: left at 90 degrees to the left, front straight and right at 90 degrees to the right.
Connect the trigger and echo pins of the sensors to pins 2 to 7 and their power to 5 V and GND.
Connect the L298N inputs to pins 8, 9, 10 and 11, with the enable pins on PWM pins 5 and 6, and power it from the battery.
Write a function that returns distance in cm for each sensor with a 20 ms gap between sensors so echoes do not mix.
Write movement functions: forward, turn left 90 degrees, turn right 90 degrees and turn around, using timed turns to start with.
Code the left-hand rule decisions in loop with a threshold of 15 cm.
Add the proportional correction along a wall, adjusting the left and right wheel speeds in proportion to the error from 8 cm.
Build a simple maze and test; adjust the turn times for your floor surface until the corners are clean.
What you should see
The robot follows the left wall through the maze and reaches the exit without touching the walls in most runs.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1Why does the left-hand rule solve a maze?
Following one wall visits every part of a simply connected maze, so it must reach an exit on the outer wall.
2Why wait between sensor readings?
The echo from one sensor can be picked up by another and give wrong values.
3What does proportional correction do?
It adjusts steering in proportion to how far the robot is from its target distance.
4When does left-hand rule fail?
When the exit is in the middle of a loop in the maze, away from the outer walls.
Take it further
Make the robot map the maze and then take the shortest route on a second run.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
Free ebooks for this project
Robotics
Build an Obstacle-Avoiding Robot
An ultrasonic sensor robot that finds its own way, step by step
Robotics
Motors, Gears and Motor Drivers
Make things move: DC motors, servos, steppers and how to drive them
