Skip to content

mgalen007/Obstacle-Avoiding-Robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Obstacle-Avoiding Robot

A fully autonomous 2-wheeled robot built with an Arduino UNO and the L293D Motor Shield. This robot uses an ultrasonic sensor mounted on a servo motor to navigate through environments, backing up when it gets stuck and scanning for the best path forward.

Components

  • Microcontroller: Arduino UNO
  • Motor Driver: L293D Motor Driver Shield
  • Motors:
    • 2x DC Gear Motors (connected to M1 and M3)
    • 1x SG90 Servo Motor (connected to SER1 / Pin 10)
  • Sensor: HC-SR04 Ultrasonic Sensor (Trig: A0, Echo: A1)
  • Power: 3x 18650 Li-ion Batteries (~11.1V - 12.6V)

Pinout

The L293D Shield simplifies wiring. Ensure connections match the following:

Component Shield Terminal / Pin Description
Left Motor M1 Drive motor
Right Motor M3 Drive motor
Servo Motor SER1 (Pin 10) Pan motor for sensor
Ultrasonic Trigger A0 Trigger pulse
Ultrasonic Echo A1 Echo return
Battery (+) M+ External power input
Battery (-) GND Common ground

IMPORTANT: Remove the PWR Jumper on the shield if powering the Arduino via USB while batteries are connected to prevent damage.

Navigation Logic

The robot follows a "Scan-Decide-Act" loop:

  1. Drive – Move forward at constant speed
  2. Detect – If obstacle detected within 15cm:
    • Stop and move backward for 400ms to create space
  3. Scan – Servo rotates sensor left and right
  4. Compare – Arduino compares distance readings from both sides
  5. Turn – Robot turns toward the most open space and resumes forward movement

Installation & Setup

Required Libraries

  • Install Adafruit Motor Shield V1 via the Arduino Library Manager

Configuration

  • Servo Alignment: Adjust myServo.write() values in code if needed to ensure 180° points forward
  • Motor Polarity: If the robot spins in place instead of moving forward, swap the wires of one motor on the terminal block

About

Program for a smart obstacle-avoiding robot car using Arduino.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages