This project implements an autonomous line-following and maze-solving robot built on the ESP-IDF framework using ESP-IDF.
The robot is capable of:
- Following a black line using a PID-based control system
- Detecting and navigating junctions (left, right, T, and U-turns)
- Detecting objects using an IR sensor and pushing them forward
- Detecting the end of the maze and stopping precisely
- Real-time PID tuning through an integrated HTTP tuning server
The robot uses a 5-channel line sensor array to read surface reflectance values. These readings are normalized, processed, and used to calculate an error signal which drives a PID controller.
The PID output adjusts motor speeds dynamically to keep the bot centered on the line.
In addition to line following, the bot intelligently handles:
- T-junctions, left turns, right turns, and U-turns
- End detection to stop at maze completion
- Box detection using an IR proximity sensor (GPIO input)
- Automatic push mechanism when a box is detected on its path
Sensor values are mapped between LSA_MIN and LSA_MAX and inverted for consistent logic.
The robot computes:
error— deviation from the center of the linecorrection— proportional + integral + derivative adjustments
Motor speeds are tuned as:
left_duty = OPT_DUTY + correction
right_duty = OPT_DUTY - correction
When IR sensor (GPIO 0) detects an object:
- Robot moves forward briefly to push the box
- Reverses and realigns itself on the track
After executing a left turn, the robot verifies if it has reached the end of the path using line sensor conditions and timing.
-
Clone the repository:
git clone https://github.com/varun05050505/Maze-solving-bot.git
-
Set up the ESP-IDF environment:
. $HOME/esp/esp-idf/export.sh
-
Flash the code
idf.py build idf.py -p /dev/ttyUSB0 flash monitor
