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. Both jumper pairs (J2/J3 for ENA and J8/J9 for ENB) are removed from the L298N module to enable external PWM control. This allows independent speed adjustment for each motor to compensate for mechanical differences.
| 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 |