Arduino Obstacle Avoiding Robot

Arduino Obstacle Avoiding Robot Construction
In this blog post, we will discuss how to build an obstacle avoiding robot kit using Arduino Uno.
What is an Obstacle Avoiding Robot?
An obstacle avoiding robot prevents a moving vehicle from colliding with obstacles by controlling its surroundings with sensors. According to your software, it determines its own path without colliding with obstacles. Sensors like Hc-sr04 or Mz80 are ideal for this project. We will use hc-sr04 in our project.
Required Materials
- Arduino Uno
- 2-Wheel Transparent Chassis Car Kit
- L298N Voltage Regulated Dual Motor Driver Board
- Ultrasonic Sensor HC-SR04
- 6-Slot AA Battery Holder
- Battery (We recommend using a 2s lipo battery for rechargeable and high efficiency.)
- Jumper Cables
Circuit Diagram

Arduino Codes
#define echoPin 12 //Echo pin of the Ultrasonic sensor connected to pin 12 of Arduino
#define trigPin 13 //Trig pin of the Ultrasonic sensor connected to pin 13 of Arduino
#define MotorR1 7
#define MotorR2 6
#define MotorRE 9 // Define motor pins
#define MotorL1 5
#define MotorL2 4
#define MotorLE 3
long duration, distance; // Define two variables for duration and distance
void setup() {
// Since the ultrasonic sensor sends waves from the Trig pin, it is defined as OUTPUT,
// and since it receives these waves from the Echo pin, it is defined as INPUT.
pinMode(echoPin, INPUT);
pinMode(trigPin, OUTPUT);
pinMode(MotorL1, OUTPUT);
pinMode(MotorL2, OUTPUT);
pinMode(MotorLE, OUTPUT); // Define our motors as output.
pinMode(MotorR1, OUTPUT);
pinMode(MotorR2, OUTPUT);
pinMode(MotorRE, OUTPUT);
Serial.begin(9600
Share
Blog Latest Additions

I2C Sensor Not Working: Address, Pull-up Resistor, and Connection Check
22.10.2026

Why Does a Stepper Motor Miss a Step? Current, Speed, and Load Settings
29.09.2026

How to Check Voltage, Amperage, and Connector Polarity When Choosing an Adapter?
19.09.2026

How to Use the ST750E 750W Digital AC 3-Phase Motor Speed Control Module?
03.09.2026

JST GH vs PH vs XH vs SH Connectors: Differences
27.06.2026

Low Level vs. What is High Level Trigger?
19.03.2026
.png)