Introduction: Arduino: How to Build an Obstacle Avoiding Robot

Picture of Arduino: How to Build an Obstacle Avoiding Robot

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.

My YouTube Channel. Please Subscribe for Support


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

Step 1: Video Tutorial : Just 6 Minutes - Watch and Make...

Arduino Tutorial : How To Build An Obstacle Avoiding Robot

Watch carefully

Step 2: Materials : Necessary Materials and Equipments

Picture of Materials : Necessary Materials and Equipments

* Arduino Uno R3

* Adafruit Motor Shield

*HC-SR04 Ultrasonic Module Distance Sensor for Arduino

* Tower Pro SG90 RC Mini Servo Motor

* Bracket / Holder for HC-SR04

* DC Motors and Wheels

* Bovine Wheel

* Plate or something like that

* Jumper

* Battery Buckle 9V

* Battery 9V

* Glue Gun or Cable Ties

Step 3: A Chassis and Sensor Connections

Picture of A Chassis and Sensor Connections

A Chassis

Attaching The Arduino To The Chassis

Connecting The Sensor To The Arduino

Step 4: Motors and Motor Shield Connections

Picture of Motors and Motor Shield Connections

Attaching The Motor Shield To The Ardunio

Connecting Motors To The Shield

Step 5: Programming the Robot

Picture of Programming the Robot

Step 6: For Me + What's Next ?

Picture of For 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 Mert . Likes Math, Computers, Robotics and programming. I've just started a youtube channel, hoping to help people, share some of my knowledge and learn myself.

My YouTube Channel

My next Youtube (and Instructables) tutorials will deal with different methods of controlling electronics (Smartphone-Bluetooth control, 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). so make sure you are a subscriber so you won't miss them, and I will see you next time.

Bye !

Comments

Voltrex085 made it! (author)2017-08-02

I really liked this design, and thanks for telling us how to upload the codes from all the libraries. Mine turned out ok, but it only moves in a straight direction for about a second, then rotates again. MertArduino, Is their anyway to reduce the sensor's parameter within the coding, and if so can you reply back how?

harshitkrishna04 (author)2017-06-27

sir my robot is not working the program is verified and uploaded but it is not working the servo motor is not rotating and the wheels are also not rotating

only the motorshield and ardunio are getting the current supply and a buzzing sound is been heard anda pop sound after a intervel of time .

harshitkrishna04 (author)2017-06-12

how to upload the program in the ardunio

Kanak Shilledar RM (author)2017-01-22

Your program is giving errors it is not working correctly.

please check it positively.

Why do you think it's not correct? Maybe you made a mistake! If you are getting an error, first share the error. Maybe then I can help you.

sajjad751 (author)2016-12-07

can u give me the code on text pad

MertArduino (author)sajjad7512016-12-07

You can copy from here: http://mertarduinotutorial.blogspot.com.tr/2016/12/arduino-project-tutorial-01-obstacle.html

sajjad751 (author)MertArduino2016-12-08

thanks!

MertArduino (author)2016-12-08

Please watch this tutorial; https://youtu.be/Es8D1q_b-c4

King H4rsh (author)2016-11-05

Sir here are the errors.

WannaDuino made it! (author)King H4rsh2016-11-12

if needed i wil help you

pleace tell me what boards you use and if you exact connect it like the IBLE.

make pictures ,please.

its not difficult, i know that's easy to say, but if you let me help. we will get it done.

and let me tell you this, (i wil even let your motors make a party sound, watch me) you will all understand it when we go do it. hahahaha.

some of the people here know exactly what i mean. (its music to my ears.)

And look at mine, O YES its a Police robot with front and back lights

he is called KNIGHTRIDER.

WannaDuino!!!

MertArduino (author)WannaDuino2016-11-15

Congratulations for your work. But I helped my followers. Just like I helped you. ;)

This comment has been a bit disrespectful. :/

I think you should open an instructables account, you can share your work from your own account.

MertArduino (author)King H4rsh2016-11-06

You sent 5 different codes. They all made an error! Where's my code? And why are there 5 codes? Download my code again! Do what I told you before and upload it! Do not forget to install NewPing and AFMotor.h libraries. And do not run my code directly! Just copy it. Then open a new page in Arduino and paste it. Connect the robot, choose which port you have connected and upload it!

WannaDuino made it! (author)2016-11-12

Thank you so much,

I MADE IT!!!!

WannaDuino!!! made it. YES.

And not like you told, by blank screen and copy your code in it.

i added the LIBRAIRYS to mine, and then opened the scketch code of you.

and it finaly works. But not 100% but it rides and somtimes banges up to somthing, but that i wil look after tommorow.

I just wanted you to tell this GOOD IBLE news friend.

WannaDuino!!!

MertArduino (author)WannaDuino2016-11-15

Congratulations. I hope it helps ;)

King H4rsh (author)2016-11-03

See sir

MertArduino (author)King H4rsh2016-11-05

Only the rotation of the wheels may not be equal. If this is the case, it is enough to replace the DC motor connections in the motor shield.

King H4rsh (author)2016-11-04

Sir please help me I really need to know

MertArduino (author)King H4rsh2016-11-05

Connections seem right. Is there any problem?

King H4rsh (author)2016-11-03

5&6

King H4rsh (author)2016-11-03

4

King H4rsh (author)2016-11-03

3

King H4rsh (author)2016-11-03

2

King H4rsh (author)2016-11-03

Sir in the 2nd step you wrote install arduino libraries , does that mean the af Motor and new ping 7 or something else ?

MertArduino (author)King H4rsh2016-11-03

If you installed libraries, you can try. If you get any errors write me again.

King H4rsh (author)2016-11-03

Do I install your code as a library?

King H4rsh (author)2016-11-02

It happened even after following your instructions. Sir my project is due in 2 weeks so please help me.

MertArduino (author)King H4rsh2016-11-02

If there is a continuation of the error code, send it as well. If it's just that; Copy the whole code and close the IDE window. Then open the Arduino IDE again. Open a new window. Delete the contents. And paste the code. Make sure the COM entry is correct. (For example COM5 - COM8 and so on). Finally, upload the code. Use Windows 10? Did you download the Arduino program from the Windows market or is the arduino from its official website?

MertArduino (author)MertArduino2016-11-02

And check following;

I will explain step by step. I hope it helps.

1) It is already installed on the Arduino IDE

2) First Install the Arduino Library.

2.1) Before you can use the Motor shield, you must install the AF_Motor Arduino library.

a) First, grab the library from github : https://codeload.github.com/adafruit/Adafruit-Motor-Shield-library/legacy.zip/master

b) Uncompress the ZIP file onto your desktop

c) Rename the uncompressed folder AFMotor

d) Check that inside AFMotor is AFMotor.cpp and AFMotor.h files

e) Place the AFMotor folder into your arduinosketchfolder/libraries folder. For Windows, this will probably be something like MY Documents/Arduino/libraries for Mac it will be something likeDocuments/arduino/libraries. If this is the first time you are installing a library, you'll need to create the libraries folder. Make sure to call it libraries exactly, no caps, no other name.

f) Check that inside the libraries folder there is the AFMotor folder, and inside AFMotor isAFMotor.cpp AFMotor.h and some other files

g) If open Arduino IDE pls quit.

2.2) You must install the NewPing.h library.

a) Download v1.7 : https://bitbucket.org/teckel12/arduino-new-ping/downloads


b) Uncompress the ZIP file onto your desktop

c) NewPing Folder copy and paste in libraries folder

3) My code edit and use

a) Download my Arduino code : https://drive.google.com/drive/folders/0B8SAF49tU-QoVkc5VTVONDRZZ3M

b) Open the Arduino IDE and Create New Page. Delete everything in the page. Keep empty page

c) Open downloaded code (my code) in different page. Copy my code and paste in opens you to the previous page (empty page)

d) Save as and quit IDE.

e) Open IDE (It would probably be the last display saved pages)

f) You should see now active in the dark and red tones (afmotor.h and newping.h)

e) Now Upload to Arduino

King H4rsh (author)2016-10-30

Like this ?

MertArduino (author)King H4rsh2016-10-30

I'm warning you! bare wires should not be touch each other! You need to work more carefully. It can damage the Arduino.

When you solve the problem would be correct connections.

MertArduino (author)2016-10-30

I will explain step by step. I hope it helps.

1) It is already installed on the Arduino IDE

2) First Install the Arduino Library.

2.1) Before you can use the Motor shield, you must install the AF_Motor Arduino library.

a) First, grab the library from github : https://codeload.github.com/adafruit/Adafruit-Motor-Shield-library/legacy.zip/master

b) Uncompress the ZIP file onto your desktop

c) Rename the uncompressed folder AFMotor

d) Check that inside AFMotor is AFMotor.cpp and AFMotor.h files

e) Place the AFMotor folder into your arduinosketchfolder/libraries folder. For Windows, this will probably be something like MY Documents/Arduino/libraries for Mac it will be something likeDocuments/arduino/libraries. If this is the first time you are installing a library, you'll need to create the libraries folder. Make sure to call it libraries exactly, no caps, no other name.

f) Check that inside the libraries folder there is the AFMotor folder, and inside AFMotor isAFMotor.cpp AFMotor.h and some other files

g) If open Arduino IDE pls quit.

2.2) You must install the NewPing.h library.

a) Download v1.7 : https://bitbucket.org/teckel12/arduino-new-ping/downloads


b) Uncompress the ZIP file onto your desktop

c) NewPing Folder copy and paste in libraries folder

3) My code edit and use

a) Download my Arduino code : https://drive.google.com/drive/folders/0B8SAF49tU-QoVkc5VTVONDRZZ3M

b) Open the Arduino IDE and Create New Page. Delete everything in the page. Keep empty page

c) Open downloaded code (my code) in different page. Copy my code and paste in opens you to the previous page (empty page)

d) Save as and quit IDE.

e) Open IDE (It would probably be the last display saved pages)

f) You should see now active in the dark and red tones (afmotor.h and newping.h)

e) Now Upload to Arduino

WannaDuino made it! (author)2016-10-23

look

almost only the codes/librairies?????? or so

MertArduino (author)WannaDuino2016-10-30

Congratulations. I like it ;)

WannaDuino (author)MertArduino2016-10-30

i need HELP
how to code it
pleace help
how and in wat way to get it running with your code and librairy
how exactly do i put it in arduino IDE
i am new to this.

MertArduino (author)WannaDuino2016-10-30

I will explain step by step. I hope it helps.

1) It is already installed on the Arduino IDE

2) First Install the Arduino Library.

2.1) Before you can use the Motor shield, you must install the AF_Motor Arduino library.

a) First, grab the library from github : https://codeload.github.com/adafruit/Adafruit-Motor-Shield-library/legacy.zip/master

b) Uncompress the ZIP file onto your desktop

c) Rename the uncompressed folder AFMotor

d) Check that inside AFMotor is AFMotor.cpp and AFMotor.h files

e) Place the AFMotor folder into your arduinosketchfolder/libraries folder. For Windows, this will probably be something like MY Documents/Arduino/libraries for Mac it will be something likeDocuments/arduino/libraries. If this is the first time you are installing a library, you'll need to create the libraries folder. Make sure to call it libraries exactly, no caps, no other name.

f) Check that inside the libraries folder there is the AFMotor folder, and inside AFMotor isAFMotor.cpp AFMotor.h and some other files

g) If open Arduino IDE pls quit.

2.2) You must install the NewPing.h library.

a) Download v1.7 : https://bitbucket.org/teckel12/arduino-new-ping/downloads


b) Uncompress the ZIP file onto your desktop

c) NewPing Folder copy and paste in libraries folder

3) My code edit and use

a) Download my Arduino code : https://drive.google.com/drive/folders/0B8SAF49tU-QoVkc5VTVONDRZZ3M

b) Open the Arduino IDE and Create New Page. Delete everything in the page. Keep empty page

c) Open downloaded code (my code) in different page. Copy my code and paste in opens you to the previous page (empty page)

d) Save as and quit IDE.

e) Open IDE (It would probably be the last display saved pages)

f) You should see now active in the dark and red tones (afmotor.h and newping.h)

e) Now Upload to Arduino

King H4rsh made it! (author)2016-10-29

Image1- When I connect the sensor and Motor shield to UNO board. Image2- When I connect Motor shield to UNO board on one side the needles are put in properly. Image3- the needs are not pout in properly. Is that normal ?

MertArduino (author)King H4rsh2016-10-30

It's a great idea, but not helpful. Now, you must cut off the end of the wire. So you should cut the cable headers you want to attach to the motor drive. Then peel off the end of a small amount of wires. Connect in this way the cables to motor drive.

Be sure to watch the video carefully.

like these

King H4rsh (author)2016-10-20

I am an absolute beginner for robotics and I only know how to code scratch. So for the code can I just open the file in arduino ide app on my pic and program it ?

MichaelM1003 (author)2016-10-16

sir i would like to ask for your email for a lot of questions if you won't mind sir. Just an 18 year old student, still new to arduino projects. Thank you so much sir.

MertArduino (author)MichaelM10032016-10-16

bilgi.programci@gmail.com

ViệtH17 made it! (author)2016-09-13

excure me !!!

MertArduino (author)ViệtH172016-09-13

Please try the followings;

- Install the required libraries (Please check)

- Open the Arduino editor (New / Empty page)

- After download the my code

- Downloaded code open different page. Copy code and paste in new (empty) page

- Save as and quit (restart)

- Open the editor again and upload code

If all connections true, this will be the solution

Write again if it does not work. Good luck with

ViệtH17 (author)ViệtH172016-09-13

I added AFmotor to libraries but It still error. Please ,help me !!!

DylanD581 (author)2016-08-10

Great beginner robotics project!

MertArduino (author)DylanD5812016-08-10

Thank you so much..

MertArduino (author)2016-08-07

One friends left comment as below;

" this code show error please verify your code , help me "

If have a problems like that !

Please try the followings;

- Install the required libraries (Please check)

- Open the Arduino editor (New / Empty page)

- After download the code

- Downloaded code open different page. Copy code and paste in new (empty) page

- Save as and upload Arduino Uno

If all connections true, this will be the solution

MertArduino (author)MertArduino2016-08-09

Problem solved ... Be sure to install the library

liquidhandwash (author)2016-08-06

That is a cool little bot, I will have to make one.

Thanks for your comment

About This Instructable

11,709views

167favorites

License:

Bio: For more project and tutorial visit my YouTube channel Mert Arduino and Raspberry Pi
More by MertArduino:Arduino - MPU6050 GY521 - 6 Axis Accelerometer + Gyro (3D Simulation With Processing)NodeMCU ESP8266 - WiFi Robot Car Controlled by Application (Wifi Bot / Android / IoT)Arduino - Programmable Robotic Arm (Record and Repeat of the Servo Positions)
Add instructable to: