Obstacle Avoiding Robot (Arduino)

81,382

61

73

Introduction: Obstacle Avoiding Robot (Arduino)

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.
    • Download the NewPing.rar below
    • Extract it to the path - C:\Arduino\libraries
  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

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017

Wheels Contest 2017

Participated in the
Wheels Contest 2017

Arduino Contest 2017

Participated in the
Arduino Contest 2017

2 People Made This Project!

Recommendations

  • Metal Contest

    Metal Contest
  • Maps Challenge

    Maps Challenge
  • Backyard Contest

    Backyard Contest

73 Comments

0
bikeman2
bikeman2

5 months ago

I've had about a dozen HS students make this, tutorial is easy for them to follow, however they all run in circles. switching motors doesn't make any difference. Have studied the code and for the life of me can't find the problem.

0
bikeman2
bikeman2

7 months ago

I am a teacher using this robot in my course. We are having trouble getting the motors to react, they don't rotate. The servo reacts correctly when we pass our hand in front of the ultrasonic but the motors do not rotate. We have triple checked the circuit and are fairly confident that is correct. Have measured the lithium battery and we have 8.4 V at full charge.

0
nortok00
nortok00

Question 8 months ago on Step 1

Hello. I'm gathering the components needed to build this but I'm confused about the mini breadboard. All of the minis I found don't have power rails however when I looked at your pictures the only part of the breadboard I saw used are the power rails (they look detachable) so my questions are:
1. Are the power rails the only part of the breadboard you are using in this project? I ask this because I found a couple other Instructables like this that are using the entire breadboard for connecting some of the components.
2. What mini breadboard are you using (you don't have a link under the supply list) that has detachable power? Or are you simply removing the rail from a regular breadboard?

0
Nayantha KGD
Nayantha KGD

Answer 8 months ago

Hello.
You can use any type of breadboard either mini or regular one. Here I have used only the rails of a mini breadboard. In a breadboard (most of the types) has two ways of connection lines, vertically & horizontally. Please study the connection pattern in a breadboard. Once you get the idea, you can decide your connections in the robot.

0
singhyoshima994
singhyoshima994

Question 9 months ago

Only wheels are moving forward.Ultrasonic sensor is not working. Even wheels rom is low. Please advice me...... i need this urgent.

0
uthpala17
uthpala17

Question 9 months ago

PLZ HOW CONNTCT YOU

0
uthpala17
uthpala17

Question 9 months ago

Robot not working.only goes fowarad
.how to code newpin to hitapp.plz send code

0
uthpala17
uthpala17

Question 9 months ago

Robot not working.only goes fowarad
.how to code newpin to hitapp.plz send code

0
Nayantha KGD
Nayantha KGD

Answer 9 months ago

Check your connections again

0
uthpala17
uthpala17

Reply 9 months ago

Connections ok double checked.all programs done.causes.roboot not workings.plz help me.

IMG_20201101_232302.jpg
0
uthpala17
uthpala17

Reply 9 months ago

Pls send me newpin code

0
Nayantha KGD
Nayantha KGD

Reply 9 months ago

NewPing library has attached here, please find it and follow the given instructions to install it. You have to download it, unzip it and copy paste it to the arduino installed directory.

0
uthpala17
uthpala17

Reply 9 months ago

Pls tell me how to copy newpin library ide software pls

0
uthpala17
uthpala17

Reply 9 months ago

Connection ok

0
uthpala17
uthpala17

Question 9 months ago

hi. i'm new to arduino
i've already followed all the steps up there.
but when i tried to compile to coding. How to format Uno board

16039048651684103179601738756005.jpg
0
Nayantha KGD
Nayantha KGD

Answer 9 months ago

You don't need to format the UNO board before uploading the code. Just plug it to the laptop, then select the board and finally click send button. Btw the error message in your screenshot shows no turnLeft function. So check whether that fuction declared in the code.

0
stream8989S
stream8989S

1 year ago

hi. i'm new to arduino
i've already followed all the steps up there.
but when i tried to compile to coding. it say

Arduino: 1.8.10 (Windows 8.1), Board: "Arduino/Genuino Uno"
obstacle_avoiding:4:10: error: NewPing.h: No such file or directory
Multiple libraries were found for "Servo.h"
#include <NewPing.h> //Ultrasonic sensor function library. You must install this library
Used: C:\Program
^~~~~~~~~~~
compilation terminated.
exit status 1
NewPing.h: No such file or directory
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


can you help me?
i've already download the NewPingLibrary and pu it in folder
C:/ProgramFiles/Arduino?libraries

thanks

0
g3holliday
g3holliday

Reply 1 year ago

I know this might be a little late, but here it is.

Go to the "Manage Libraries" part of Arduino under Tools and search for New Ping. Then hit Install.
Thanks, g3holliday

0
sivaramalingam705
sivaramalingam705

Reply 1 year ago

Hi do you know how can we solve the problems

0
Teezeeh
Teezeeh

1 year ago

My robot is just moving in circles. I don't know how to troubleshoot it. Please help!