This is an old revision of the document!
| Author | Berescu Silvia-Maria |
|---|---|
| Series and Group | 332CD |
| GitHub | Maze Solver Robot |
This project involves building a small autonomous robot capable of navigating and escaping a maze with opaque walls, using ultrasonic sensors and a wall-follower algorithm.
Hypothesis: I believe that using the Left-Hand Wall Follower algorithm with HC-SR04 ultrasonic sensors and real-time visual feedback through an LCD will allow the robot to solve a simple maze in under 60 seconds, as the algorithm guarantees finding the exit in any simply connected maze.
The block diagram below shows all project modules and how they interact:
Main modules and their roles:
| No. | Component | Qty | Role |
|---|---|---|---|
| 1 | 2WD chassis kit (line follower) | 1 | Mechanical platform |
| 2 | ATmega328P-XMINI | 1 | Main microcontroller |
| 3 | L298N motor driver module | 1 | DC motor control via PWM |
| 4 | HC-SR04 ultrasonic sensor | 2 | Obstacle detection |
| 5 | LCD 16×2 with I2C module (PCF8574) | 1 | Robot status display |
| 6 | 18650 Li-ion battery 2500mAh | 2 | Autonomous 7.4V power |
| 7 | Dual 18650 charger | 1 | Battery recharging |
| 8 | 2×18650 battery holder + switch | 1 | Battery mount + ON/OFF |
| 9 | Male-female dupont wires | 40 | Component connections |
| 10 | 400-point breadboard | 1 | Connection prototyping |
The ATmega328P-XMINI board uses Arduino-style pin labels (D2, D3, A4 etc.) which correspond to the internal ATmega328P port/pin names. The table below clarifies this mapping for all pins used in this project:
| Arduino Label | ATmega Port/Pin | Physical Pin (DIP) | Used For |
|---|---|---|---|
| D2 | PD2 | 4 | HC-SR04 Front — TRIG |
| D3 | PD3 (INT1) | 5 | HC-SR04 Front — ECHO |
| D4 | PD4 | 6 | HC-SR04 Left — TRIG |
| D5 | PD5 (OC0B) | 11 | L298N ENB — PWM Motor Right |
| D6 | PD6 (OC0A) | 12 | L298N ENA — PWM Motor Left |
| D8 | PB0 | 14 | L298N IN1 |
| D9 | PB1 | 15 | L298N IN2 |
| D10 | PB2 | 16 | L298N IN3 |
| D11 | PB3 | 17 | L298N IN4 |
| D12 | PB4 | 18 | HC-SR04 Left — ECHO |
| A4 | PC4 (SDA) | 27 | LCD I2C — SDA |
| A5 | PC5 (SCL) | 28 | LCD I2C — SCL |
| VCC (pin 7) | VCC | 7 | 5V power input |
| VCC (pin 20) | VCC | 20 | 5V power input |
| GND (pin 8) | GND | 8 | Ground |
| GND (pin 22) | GND | 22 | Ground |
D3 (PD3/INT1): connected to the INT1 external interrupt line, used for precise ECHO pulse measurement on the front sensor. Interrupt-driven measurement is more accurate than polling because the ATmega reacts instantly to the signal edge without busy-waiting.
D5 (PD5/OC0B) and D6 (PD6/OC0A): both are hardware PWM outputs of Timer0 (Channel B and Channel A respectively). Using both channels allows independent speed control of each motor, which is essential for straight-line driving — real DC motors are never perfectly identical and require small speed corrections.
D12 (PB4): plain GPIO pin used for HC-SR04 Left ECHO via polling. D12 has no special hardware function requirements since the left sensor uses software polling.
The schematic uses net labels instead of long wires for clarity. Two pins sharing the same net label name are electrically connected.
The L298N receives direction signals on IN1–IN4 from ATmega pins D8–D11:
| IN1 | IN2 | Motor Left behavior |
|---|---|---|
| HIGH | LOW | Forward |
| LOW | HIGH | Reverse |
| LOW | LOW | Stop |
The same logic applies to IN3/IN4 for Motor Right.
Speed is controlled via PWM on both ENA (D6/OC0A) and ENB (D5/OC0B) using Timer0 Fast PWM mode.This allows independent speed adjustment for each motor to compensate for mechanical differences.
The image shows the fully wired robot with all components mounted and powered via the 2×18650 battery pack (7.4V).
output of the L298N module. The onboard amber LED is lit, confirming the board is receiving stable 5V power from the battery pack through the L298N regulator. GND from the ATmega is connected to the breadboard ground rail to establish a common ground reference for all components. * L298N motor driver — all 4 red indicator LEDs
are on, confirming the module is powered and IN1–IN4 lines are in a defined logic state. The 5V regulated output feeds the breadboard power rail which distributes power to all logic components. * **LCD 16x2 I2C** — the blue backlight is on, confirming the LCD
module is receiving stable 5V power from the battery pack via the L298N regulated output. No characters are displayed yet as the firmware has not been uploaded at this stage. I2C communication will be verified once the ATmega is programmed.
and left sensors are mounted and connected to ATmega via the breadboard.
L298N to all logic components. The red (+) rail carries 5V and the blue
(-) rail carries GND, with the ATmega GND also connected to the same rail for common ground. * **Battery holder 2x18650** — mounted on the chassis.
are in a defined state, confirming correct power wiring.
working, supplying stable power to the LCD module via the breadboard power rail.
breadboard ground rail shared with L298N, sensors and LCD, ensuring
all components share the same voltage reference.
| Lab concept | Usage in project |
|---|---|
| GPIO | TRIG/ECHO sensor pins, motor direction pins IN1–IN4 |
| PWM | Timer0 Fast PWM on OC0A (D6) and OC0B (D5) — both motors |
| I2C | TWI communication with LCD 16×2 via PCF8574 on A4/A5 |
| UART | Debug data transmission at 9600 baud via TX (D1) |
| Interrupts | INT1 on D3 (PD3) for precise front ECHO pulse measurement |
The robot uses the Left-Hand Wall Follower algorithm:
| Week | Activity | Status |
|---|---|---|
| Week 1 | Component selection, ordering parts | Done |
| Week 2 | Chassis assembly, mounting motors and wheels | Done |
| Week 3 | L298N wiring + electrical schematic | Done |
| Week 4 | HC-SR04 integration + distance measurement test | Planned |
| Week 5 | LCD I2C integration + data display | Planned |
| Week 6 | Navigation algorithm implementation + maze test | Planned |
| Week 7 | 90° turn calibration, code optimization, final demo | Planned |