Obstacle Avoiding Robot (Arduino)

24,481

31

29

About: Student at University of Colombo

Here i'm going to instruct you about making an Obstacle Avoiding Robot based on Arduino. I hope to do step by step guide on making this robot in very easy way. An obstacle avoiding robot is a fully autonomous robot which can be able to avoid any obstacle which it face when it move. Simply, when it met an obstacle while it moving forward, automatically stop moving forward and makes a step back. Then it looks it's two sides left & right and starts to move the best possible way; which means either in left direction if there is another obstacle in right or in right direction if there is another obstacle in left side. The obstacle avoiding robot is very helpful and it is the base of many large projects such as Automatic cars, robots used in Manufacturing factories, even in robots used in spacecrafts.

Step 1: What You Need in This Project:

  1. Arduino UNO - https://www.ebay.com/p/Arduino-UNO-R3-Board-With-...
  2. Smart robot car chassis with 2 x toy car wheels and 1 x Universal wheel (or ball casters) - https://www.ebay.com/itm/Motor-New-Smart-Robot-Ca...
  3. Two DC motors - https://www.ebay.com/itm/Arduino-Smart-Car-Robot-...
  4. L298n motor driver - https://www.ebay.com/itm/New-L298N-DC-Stepper-Moto...
  5. HC-SR04 Ultrasonic Sonar sensor - https://www.ebay.com/itm/Ultrasonic-HC-SR04-HC-SR0...
  6. TowerPro micro servo 9g - https://www.ebay.com/itm/6X-TowerPro-SG90-Mini-Gea...
  7. 7.4V 1300mah Lipo battery - https://www.ebay.com/itm/VOK-Lipo-Battery-for-RC-H...
  8. Jumper wires (male-to-male, male-to-female)
  9. Mini breadboard

  10. Ultrasonic sonar sensor mounting bracket

  11. Screws and nuts
  12. Screwdriver
  13. Soldering iron
  14. Double sided tape(optional)
  15. Hot glue gun(optional)

Step 2: Assembling the Chassis

Solder two wires to each DC motor. Then fix two motors to the chassis using the screws. If you need any clarification, please watch this youtube video https://www.google.lk/url?sa=t&rct=j&q=&esrc=s&sou... and it will show you how to assemble the Smart 2WD Robot car chassis. Finally attach the Universal wheel (or ball caster wheel)

Step 3: Mount the Components

Mount the Arduino UNO, L298n motor driver and TowerPro servo motor on the chassis. Note: when mounting the arduino board, leave enough space to plug the USB cable, since later you have to program the arduino board by connecting the it to the PC via a USB cable.

Step 4: Preparing the Ultrasonic Sensor

Plug four jumper wires to the Ultrasonic sensor and mount it on the mounting bracket. Then mount the bracket on the TowerPro micro servo which has already installed on the chassis.

Step 5: Wiring Components

L298n motor driver:

+12V → Lipo battery (+)

GND → Lipo battery (- ) important: connect the GND to lipo battery (-) and to arduino board any GND pin

+5V → arduino Vin

In1 → arduino digital pin 7

In2 → arduino digital pin 6

In3 → arduino digital pin 5

In4 → arduino digital pin 4

OUT1 → Motor 1

OUT2 → Motor 1

OUT3 → Motor 2

OUT4 → Motor 2

Breadboard:

Connect two jumper wires to arduino board 5V and GND pins, then connect both wires to breadboard. now you can use this as +5V supply.

HC-SR04 Ultrasonic Sonar sensor:

VCC → breadboard +5V

Trig → arduino analog pin 1

Echo → arduino analog pin 2

GND → breadboard GND

TowerPro micro servo 9g:

orange wire → arduino digital pin 10

red wire → breadboard +5V

brown wire → breadboard GND


Step 6: Programming Arduino UNO

  1. Download and Install the Arduino Desktop IDE
  2. Download and paste NewPing library (Ultrasonic sensor function library) file to the Arduino libraries folder.
  3. Download and open obstacle_avoiding.ino
  4. Upload the code to the arduino board via a USB cable

Step 7: Power the Robot

Connect the Lipo battery to the L298n motor driver as follows:

Lipo battery (+) → +12V

Lipo battery (- ) → GND

Step 8: Great !!!

Now your robot is ready to avoid any obstacle....

I would be happy to answer any questions you have

email me: dnayantha88@gmail.com

search me on facebook and linkedin for more projects - Danusha nayantha

Thank You

Share

    Recommendations

    • Arduino Contest 2019

      Arduino Contest 2019
    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure

    29 Discussions

    0
    None
    96SVE

    7 weeks ago

    maybe this is too much but i would like an detailed explanation of how it works.like if the motor driver only moves de dc motors forwards and backwards how does the car go left or right before moving forward or backwards

    0
    None
    ShivaniS53

    2 months ago

    How do I control the speed of the dc motors? It's going too fast.

    2 replies
    0
    None
    ShivaniS53ShivaniS53

    Reply 7 weeks ago

    How do I do that? Can you please give me the connections I need to change and the part of the code I need to edit?
    0
    None
    Star RobaticsShivaniS53

    Reply 2 months ago

    In order to control motor speeds, u need to use technique called "PWM" in arduino. Then you will have to modify this code and also some connections to motor driver as well.

    0
    None
    YarneS

    Question 8 weeks ago on Step 8

    Hello,

    The HCSR04 sensor works if i put my hand infront of it, but the wheels don't spin. I think they are supposed to spin from the start till he reaches the obstacle and then the sensor looks for a diffrent direction. I downloaded the NewPing library and installed it into the arduino/library.

    I checked twice but it sill doesn't work. the motor works if you connect the battery. so that isn't the problem. Any suggestions ?

    0
    None
    PRUDHVI RAJJ

    3 months ago

    i wanted to do this project ,is it possible for me to do this by following all your instructions ???

    1 reply
    0
    None
    HarimauH

    Question 5 months ago

    hi, after follow your instructions, still have errors..

    10 answers
    0
    None
    HarimauHStar Robatics

    Reply 4 months ago

    error when I want to add Ultrasonic sensor function library..

    error1.jpg
    0
    None
    Star RobaticsHarimauH

    Reply 4 months ago

    Check whether the library exists in the specified file directory or if it doesn't ,please copy it to the directory

    0
    None
    HarimauHHarimauH

    Reply 4 months ago

    Did pin ENA and ENB connected to UNO?

    0
    None
    Star RobaticsHarimauH

    Reply 4 months ago

    Nope.
    It is for control motor speeds. Here motors are spinning at constant speed.

    0
    None
    HarimauHStar Robatics

    Reply 4 months ago

    I follow all the step, but only sensor n servo function. motor not function

    0
    None
    Star RobaticsHarimauH

    Reply 4 months ago

    Check power supply.
    Most importantly the GND connections

    0
    None
    Star RobaticsHarimauH

    Reply 4 months ago

    What are the power sources you have employed?
    Note that, the negative supply(-) of the battery must be connected to motor driver GND as well as to arduino UNO GND

    0
    None
    FuyunL

    11 months ago

    Good instructions.

    Can you tell me how to fix the step motor on the base? Thanks.

    1 reply
    0
    None
    Star RobaticsFuyunL

    Reply 11 months ago

    This smart car robot chassis isn't compatible with the stepper motors. But you can attach it to the base using a stepper motor bracket and making a hole using a drill.