🛠️ MAKER GUIDEJul 03, 2026•⏱️ 3 min read•🇳🇵 Tested in Nepal
Autonomous Obstacle Avoidance Robot Car with HC-SR04 and L298N
Build a smart obstacle-navigating autonomous robot car using the Smart Car Chassis, SG90 servo scanning, and L298N H-Bridge motor driver.
🛠️ BILL OF MATERIALS (BOM)
Required Hardware & Component Checklist
Curated components verified for this project. Check the items you need, adjust quantities, and add straight to cart:
Estimated Total (7/7 items):
NPR 3,800
✓ Cash on Delivery across Nepal
All parts selected
NPR 1,300
NPR 350
NPR 250
NPR 200
NPR 1,200
NPR 100
NPR 400
(NPR 200 ea)
Autonomous Obstacle Avoidance Robot Car with HC-SR04 and L298N
Educational Notes
This project is designed to be accessible to students from Class 4 to Masters level, with complexity scalable to match different age groups and skill levels.
Learning Objectives:
- Understand basic electronics and circuitry principles
- Learn sensor applications and data collection techniques
- Develop problem-solving skills through hands-on building and troubleshooting
- Apply programming concepts to control hardware and process data
- Connect projects to real-world Nepalese contexts and challenges
Adaptability:
- For younger students (Class 4-8): Focus on assembling pre-built circuits, observing results, and understanding basic concepts
- For intermediate students (Class 9-12): Modify code, experiment with parameters, and explore underlying principles
- For advanced students (Undergraduate/Masters): Optimize designs, add features, conduct research extensions, and analyze performance
Safety Note: Always supervise younger students when working with electricity, heat, or moving parts.
Build a 4WD autonomous robot car using the HC-SR04 Ultrasonic Sensor, SG90 Servo, and L298N Motor Driver.
Hardware Bill of Materials:
- Microcontroller: UNO R3 ATMEGA328P-PU Development Board with 30cm cable
- Motor Driver: L298N Dual H Bridge DC Stepper Motor Drive Controller Board Module
- Sensor: HC-SR04 ultrasonic sensor / ultrasonic range / ultrasonic module
- Pan Servo: SG90 9g Micro Servo Motor 180 Degree
- Chassis & Power: Smart Robot Car Chassis Kit + 18650 Battery Box 2S + 2x 18650 3.7V 3000mAh Battery
Circuit Pinout & Wiring Connections:
| Component / Module Pin | Arduino Uno Pin | Function / Description |
|---|---|---|
| L298N IN1 / IN2 | Pin D4 / Pin D5 | Left Motors Forward / Reverse |
| L298N IN3 / IN4 | Pin D6 / Pin D7 | Right Motors Forward / Reverse |
| L298N ENA / ENB | Pin D3 / Pin D11 (PWM) | Left / Right Motor Speed Regulation |
| SG90 Servo PWM | Pin D9 | Sonar Pan Scanning (0° - 180°) |
| HC-SR04 TRIG / ECHO | Pin D8 / Pin D2 | Ultrasonic Range Sensing |
| 18650 2S Battery (+7.4V/GND) | L298N 12V In & Arduino VIN | High Current Drive Supply |
Firmware Source Code (Arduino Mega 2560 C++)
#include <Wire.h>
#include <EEPROM.h>
// L298N Motor Driver Pin Connections
const int ENA = 5;
const int IN1 = 18;
const int IN2 = 19;
const int IN3 = 21;
const int IN4 = 22;
const int ENB = 23;
void setup() {
Serial.begin(9600);
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
Serial.println("Robotic Chassis & Motor Driver Controller Active.");
}
void moveForward(int speedVal) {
analogWrite(ENA, speedVal);
analogWrite(ENB, speedVal);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
void loop() {
Serial.println("Executing Autonomous Drive Routine Forward...");
moveForward(200);
delay(3000);
Serial.println("Stopping Motors...");
stopMotors();
delay(2000);
}
← Previous Guide
Offline Voice-Controlled Smart Home Automation with ESP32 & Relays
Next Guide →
Biometric Fingerprint Attendance Register with R307 & 1602 I2C Display
