OBSTACLE AVOIDING ROBOT USING L293 Motor Driver shield

 

 Obstacle Avoiding Robot Using Arduino UNO

Build a smart robotic car that automatically detects and avoids obstacles using an ultrasonic sensor. This beginner-friendly robotics project is perfect for learning automation, sensors, and embedded systems.

The robot uses Arduino Uno as the main controller and an HC-SR04 to measure distance.


 Components Needed

  • Arduino Uno

  • HC-SR04

  • L293D Motor Driver Shield

  • 2 or 4 DC Motors

  • Robot Chassis

  • Wheels

  • Jumper Wires

  • Battery (7.4V–12V recommended)


 Working Principle

  1. The ultrasonic sensor continuously measures the distance ahead.

  2. If no obstacle is detected → Robot moves forward.

  3. If an obstacle is closer than 15 cm:

    • Robot stops

    • Turns left or right

    • Continues moving forward

All decisions are controlled by the Arduino.


 Ultrasonic Sensor Working

The HC-SR04 sensor works using sound waves.

Step-by-Step Process:

1️⃣ Trig Pin sends ultrasonic pulses.
2️⃣ Sound waves travel and hit an obstacle.
3️⃣ Echo Pin receives the reflected signal.
4️⃣ Arduino measures the time taken.
5️⃣ Distance is calculated using a formula.


 Distance Calculation Formula

distance = (time × speed of sound) / 2

Speed of sound:

  • 343 m/s

  • 0.0343 cm/µs

Division by 2 is needed because the sound travels to the object and back.


 Basic Connection Overview

Ultrasonic Sensor:

  • VCC → 5V

  • GND → GND

  • Trig → Arduino Pin 9

  • Echo → Arduino Pin 10

Motor Driver:

  • Motor pins → DC motors

  • IN pins → Arduino digital pins

  • Power → Battery supply


 Sample Arduino Code

const int trigPin = 9;
const int echoPin = 10;

long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration * 0.0343 / 2;

Serial.print("Distance: ");
Serial.println(distance);

if (distance > 15) {
moveForward();
} else {
stopRobot();
turnRight();
}

delay(500);
}

void moveForward() {
// Add motor control logic
}

void stopRobot() {
// Stop motors
}

void turnRight() {
// Turning logic
}

 Applications

✅ Autonomous robots
✅ Warehouse automation
✅ Smart delivery robots
✅ Robotics competitions
✅ STEM education projects
✅ Beginner AI navigation systems


Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course