Obstacle Avoiding Robot

321,119

238

184

This instructable is the written version of my "Arduino: How To Build An Obstacle Avoiding Robot" Youtube video that I've uploaded recently. I strongly recommend you to check it out.

So, without further ado, Let's get started !

Step 1: A Chassis !

the first step and the base of any robot is a chassis. i got mine from ebay, and i'll leave links for that. if you prefer, you can also make your own using cardboard and DC/Servo motors. Either way, the chassis has to include a body, two motors and sometimes even a battery holder and a switch.

Step 2: Brain

Now we need something that will orchestrate our motors, a micro-controller.

from the title of this instructable you probably have already understood that we are going to use Arduino.

Why?

well, the answer is simple. Arduino (or, specifically, Arduino Uno) is a compact, comfortable and relatively cheap micro-controller. In addition, it is very common and you can get it literally everywhere online.

Step 3: Attaching the Arduino to the Chassis

Now simply use some screws to attach the Arduino to the chassis. If you've made your own chassis/ can't find any screws, you can use a small amount of double-sided tape. If you do choose to use double-sided tape then search for an area under the arduino that doesn't have many pins/solder above it.

Step 4: A Sensor

In Order to make a robot that can maneuver by its own we need some sort of an input, so it can "know" or "judge" what to do. a very comfortable sensor that fits our goal (avoiding obstacles) is the Hc-sr04 ultrasonic sensor.

Scientific Explanation Of the sensor's action:

What the sensor does it is calculating the distance from an object by sending bursts of ultrasound towards it and measuring the time it takes to the sound waves to get back (Distance = Velocity * Time). we can use this information in order to determine whether there's a close "obstacle" near the robot and then- avoid it !

So now you know how an ultrasonic sensor work, Scientifically. Now, Let's use it !

Step 5: Attaching the Sensor to the Chassis

all we have to do next is to actually attach the sensor to the body. To make life easier, i recommend sticking a mini bread-board as well for easier wiring, although you don't have to.

Step 6: A Milestone

If it seems like the robot is staring at you, then you are on the correct way.

Step 7: Connecting the Sensor to the Brain

Now gather some wires, and connect the sensor to the arduino according to this diagram i made.

Pay attention that your ping sensor may have a different pin layout (e.g. 5 pins), but it should have a voltage pin, ground pin, trig pin and an echo pin.

Step 8: Connecting and Controlling the Motors With the Arduino

arduino boards can't control dc motors by their own, because the currents they are generating are too low. Moreover, the currents they are generating cannot be reversed, so you can't change the direction of the motor. To solve that we will use a motor driver, which helps the arduino control dc motors. The most comfortable way of using motor drivers is through shields. Motor shields are very cheap and i will leave links for where you can buy one online.

Step 9: Attaching the Motor Shield to the Ardunio

Take your motor shield and simply plug it into the arduino with the sensor's wires crunching inside.

Step 10: Connecting the Motors to the Shield

Every Motor Shield has (at least) two channels, one for the motors, and one for a power source. Locate the channels and plug your chassis' motors to the motors' channel, and whatever power source you are using ( e.g. AA batteries, Lithium Battery) to the power source's channel.

Step 11: Programming the Robot

After You've made your motor shield connections, From a hardware side, believe it or not, Your robot is Done. All you have to do next is to plug your arduino to your computer.

Now open this link and download the sketch i wrote: http://www.mediafire.com/download/dql27gnuljjpurr/...

Then, open it. Choose whatever board you're using and the com port of your arduino (my happens to be three). Finally, upload the sketch, and after a few seconds you should see a message stating that the upload is complete.

Note: If the code doesn't work, you may need to download the motor shield library from: https://learn.adafruit.com/adafruit-motor-shield/l...

you might need to download other libraries, depends on what motor shield you are using.

Step 12: Playing With the Robot and Code

After you've uploaded the code, unplug the arduino, connect your batteries and watch as the robot speeds forward and avoid obstacles. then, go over the code, examine it, play with it, improve it and modify it to fit your needs !

Step 13: About Me + What's Next ?

First of all, I would like to thank you for reading this guide ! I hope it helped you build your own robot and improved your knowledge about robotics and arduino.

I think now it's a good time to introduce myself. My name is Roy and I'm a 14.5 years old teenager who likes Math, Science, Computers, Robotics and programming. {Actually in case of Math, I don't really like It, But I'm pretty good at it ;)} . I've just started a youtube channel, hoping to help people, share some of my knowledge and learn myself.

https://www.youtube.com/RoyPeer1

My next Youtube (and Instructables) tutorials will deal with different methods of controlling electronics (Smartphone-Bluetooth control, TV remote control and much more) and specifically robots. There will also be videos about home automation (controlling every day appliances with your smartphone or computer using arduino/raspberry pi). so make sure you are a subscriber so you won't miss them, and I will see you next time.

Bye !

Step 14: Materials Links

17 People Made This Project!

Recommendations

  • Make it Glow Contest 2018

    Make it Glow Contest 2018
  • Optics Contest

    Optics Contest
  • Plastics Contest

    Plastics Contest

184 Discussions

0
None
StefanosK13

Question 26 days ago

good evening to everyone!
I did this project to a small chassis and everything worked alright.
Having moved to a bigger chassis and as the ultrasonic sensor in in the center,usually the moment it senses there is no object anymore and moves forward , it gets stuck on the corners of the chassis.
Is there any way i can add a command so at any moment it senses an obstacle it turns a 45 degree angle, even if there is no object visible any more and then carry on moving forward? thank you so much in advance!

project 1.jpg
0
None
Legend1995

2 months ago

any one help me for code requirements are same above

Screenshot (57).png
0
None
aimte

3 months ago

i have followed the same steps mentioned above. i have burned the code in arduino. but on supplying the power to ada-fruit.. nothing is working... only i can see lights on the ardino and ada-fruit but not even wheels are moving. please let me know how should i get the bot working.

0
None
oliverpolder

Question 7 months ago on Step 9

But, what do i do if the wires won't fit?

0
None
Harshsingh55

7 months ago

how i get the code of programming ..and how to operate i arudino plzz help me

0
None
Harshsingh55

7 months ago

sir how i get code to oberate it into ardiuno...and where is the ON and OFF button in the this robot

0
None
AnserM

1 year ago

Sir,
Can i use L298 motor drive controller
If yes, then i have a buck converter for it also.
Please tell me the pins (to which i have to connect motors to L298)
And, also give me the code.
Thanks in advance.

1 reply
0
None
AfikileSAnserM

Reply 7 months ago

I used an L298 Motor Driver. Connect the motors if you have not done so to IN1, IN2 for left and IN3 and 4 for the right.

0
None
Aanalpatel

Question 8 months ago on Introduction

I want to make the same robot using Arduino nano can you help me

0
None
adityakshitiz2017

Question 9 months ago on Step 9

can more than one wire go into the slot(don't know the term for it)? like what you mean by crunching inside?

0
None
AdieI

Question 9 months ago on Step 12

Hey mate, I want to know how many batteries had you used for this "Robot Avoiding Obstacles"?
I had used 2 Batteries (9V) for the motors and 4 cell (batteries, as a power source of H-bridge).
Need to know should I put one more Battery for Arduino of 12V?
Waiting for your reply ?

0
None
HjnogI

9 months ago

were can i get the code please thanks. <3

0
None
Aurelied3

11 months ago

Thank you for al this info. I followed all the instructions, but had a problem:
I made an object FOLLOWING car instead of an AVOIDING car. After start it turns cirkels to the left. until the sensor notices something. It follows this object, like my hand:


I know this is cool to, but can anyone help me out, i want to make it properly?
thanks!

1 reply
0
None
RGG3Aurelied3

Reply 10 months ago

you connected one motor wrong..you have to check which one of the motors going backwards(instead of forwards) when there is no obstacle to avoid.Then change the wires between them and the problem is solved:)

0
None
ArronN1

1 year ago

why does my sensor only says 0 distance turning, even though the distance from an object is very far. it doesn`t say anything else only 0... HELP>>

0
None
AnserMAhmadC12

Reply 1 year ago

Sir,
Can i use L298 motor drive controller
If yes, then i have a buck converter for it also.
Please tell me the pins (to which i have to connect motors to L298)
And, also give me the code.
Thanks in advance.

0
None
JwalaNJwalaN

Reply 1 year ago

in the picture there is only half code seen so send me full code.