Skip to content

This is an autonomous 4-wheel robot built using an Arduino Uno. It uses an HC-SR04 ultrasonic sensor mounted on a servo motor to scan its surroundings, detect obstacles, and navigate around them.

Notifications You must be signed in to change notification settings

Pradyumna-Rao/obstacle-avoiding-robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Obstacle Avoiding Robot

This is an autonomous 4-wheel robot built using an Arduino Uno. It uses an HC-SR04 ultrasonic sensor mounted on a servo motor to scan its surroundings, detect obstacles, and navigate around them.


Components

Hardware

  • Arduino Uno R3
  • L293D Motor Driver Shield
  • TT Gear Motor (4x)
  • Wheels (4x)
  • Robot Chassis
  • Servo Motor
  • Ultrasonic Sensor (HC-SR04)
  • ICR 18650 3000mAh 3.7v Rechargeable Li-ion Battery
  • 18650 Battery Holder
  • DC Power Switch
  • Male and Female Jumper wires
  • Solder

Software

  • Arduino IDE

Circuit Diagram

Here is the wiring diagram for the project.

circuit_diagram_oar_1 circuit_diagram_oar_2


Circuit Connections

1. Motor Connections

Connect the four TT Gear Motors to the L293D Motor Driver Shield's screw terminals:

  • Motor 1: Connect to M1A and M1B.
  • Motor 2: Connect to M2A and M2B.
  • Motor 3: Connect to M3A and M3B.
  • Motor 4: Connect to M4A and M4B.

2. Ultrasonic Sensor and Servo Connections

Connect the sensors directly to the Arduino pins:

  • HC-SR04 Ultrasonic Sensor:
    • VCC5V on Arduino
    • Trig → Digital Pin D8 on Arduino
    • Echo → Digital Pin D9 on Arduino
    • GNDGND on Arduino
  • Servo Motor:
    • VCC (Red wire) → 5V on Arduino
    • Signal (Yellow/Orange wire) → Digital Pin D7 on Arduino
    • GND (Brown/Black wire) → GND on Arduino

3. Motor Driver Shield and Arduino

  • The L293D Motor Driver Shield is placed directly on top of the Arduino Uno, connecting all necessary pins automatically.
  • The shield's input pins (ENA, IN1, IN2, IN3, IN4, ENB) are connected to the Arduino's digital pins (e.g., D2-D7) to control motor speed and direction.

4. Power Connections

  • Connect the ICR 18650 batteries to the battery holder.
  • Connect the positive (red) and negative (black) wires from the battery holder to the Motor Driver Shield’s VCC and GND terminals to power the motors.
  • Connect another set of wires from the battery holder to the Arduino Uno's VIN and GND pins to power the Arduino.
  • Install the DC Power Switch in series with the positive (red) wire coming from the battery holder. This will act as the master power switch for the entire robot.

Demo

Here is a picture of the finished robot:

obstacle_avoiding_bot1

Watch it in action!

thumbnail_oar_2


Working of the Components

  • Arduino Uno (The Brain): The microcontroller that runs the code. It processes data from the ultrasonic sensor and sends commands to the motor driver to control the robot's movement.

  • L293D Motor Driver Shield (The Muscle): An interface between the Arduino and the motors. Because the Arduino's pins cannot provide enough current to run the motors directly, the shield handles the high-power switching required. When placed on the Arduino, its input pins (ENA, IN1, IN2, etc.) connect to the Arduino's digital pins to control the motors' direction and speed.

  • TT Gear Motors (The Legs): These motors are responsible for propelling the robot's four wheels based on the signals received from the motor driver shield.

  • HC-SR04 Ultrasonic Sensor (The Eyes): This sensor detects obstacles. It sends out an ultrasonic pulse from its Trig pin and listens for the echo on its Echo pin. The time taken for the echo to return is used to calculate the distance to an object.

  • Servo Motor (The Neck): This motor rotates the ultrasonic sensor, allowing the robot to scan its surroundings (left, right, and center) for a wider field of view instead of just looking straight ahead.

  • DC Power Switch (The Master Control): Connected in series with the battery, this switch allows you to conveniently turn the power on and off, controlling the entire robot's power supply.


Acknowledgements

Please Note: The initial version of the code in this repository was adapted from a public tutorial on YouTube for an obstacle-avoiding robot project that I followed several years ago.

Unfortunately, I no longer have the link to the specific video or creator. I am sharing this project as a record of my learning process. My intention is to refactor, modify, and build upon this base code to add my own unique features.

If you recognize this code or know the original source, please let me know so I can provide proper attribution.

About

This is an autonomous 4-wheel robot built using an Arduino Uno. It uses an HC-SR04 ultrasonic sensor mounted on a servo motor to scan its surroundings, detect obstacles, and navigate around them.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages