Introduction: Obstacle Avoiding Robot Arduino

Picture of Obstacle Avoiding Robot Arduino

In this tutorial, you will learn how to build a robot car which will avoid the obstacles present in its path. The concept can be used and applied in various ways according to the conditions.

Pre-requisite: Arduino programming, bread board connections, ultrasonic sensor, basic electronics.

Components required:

Bread Board x 1

Aruino Uno x 1

Ultrasonic sensor x 1

DC motors x 2

Jumper cables x 10

Chassis and wheels

9v battery

Step 1: About Arduino

Picture of About Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based onWiring), and the Arduino Software (IDE), based on Processing.

Step 2: Theory & Data Collection of Ultrasonic

Picture of Theory & Data Collection of Ultrasonic

The robot works on four main aspects: data collection, data interpretation and modulation, logic designing and execution.

Data collection:
The data collection is done with the use of ultrasonic sensor. The ultrasonic sensor has a signal generator and a receiver. The signal generator generates an ultrasonic wave and transmits in the forward direction. The transmitted wave strikes any obstacle in its path and a huge part of it gets reflected. The receiver receives the reflected wave.

Data interpretation and modulation:
The obtained values from the ultrasonic sensor need to be calibrated in order to get a meaningful data (distance). The distance of the object is calculated on the basis of the time taken by the wave in the process of transmission, reflection and collection. The speed of the wave is known (equal to the speed of sound= 330m/s). Also the time taken is known (found by the ultrasonic sensor). We know that, Speed=distance/time Therefore distance= speed*time The obtained distance will be twice the distance between the sensor and the object. So by dividing the distance by a factor of 2, we will get the required distance.

Step 3: Logic Designing & Execution

Picture of Logic Designing & Execution

The main heart of the system is the arduino. The interpreted data (distance) is calculated in the previous step and now it needs to be used to design the logic of the system.

To avoid the obstacle in the path, a condition is put in the system which says: if the distance between the robot and the object gets below a certain level, turn the robot car into other direction and continue. This logic is applied to the system using basic C programming which is used in arduino.

We now have the conditions set up for the robot car. But it needs to be executed/implemented on the hardware. The hardware used is the DC motor.
Two motors are used in this process: left motor and right motor. To move the robot car forward, both the motors are turned on. To turn the robot car to avoid obstacle, one of the motor is turned off for a while, keeping the other motor on.

Step 4: Code & Circuit Design

Picture of Code & Circuit Design

Here is code and the circuit design for the project.

Step 5: Complete Robot

Picture of Complete Robot

www.bipulgupta.com

Comments

Zoe Bell (author)2017-07-17

can't seem to get it to work. I've trouble shooted

the motors work fine when i connect them up to a power supply

the ultrasonic sensor is working - it reports correct distances via the serial monitor if i hook my arduino up to my PC

I've connected the circuit correctly.

I've checked every single one of my wires to make sure they are not broken

any suggestions?

TheStudio (author)Zoe Bell2017-07-23

check your code, there could be simple errors such as missing ';' or ')', and if code is good make sure that the code uses the same digital outputs and inputs as you actually wired up.

other suggestions:

-make sure all necessary libraries are installed

-Check that you are actually transferring the code to Arduino (incorrect port, etc)

-some cheap Arduino clones won't work, buy quality or quantity but don't expect both.

26thgenius (author)2017-06-19

hello, i just wanted to ask you that is there a way to unplug it from the pc and connect a battery so that it can be tested on the ground if it's working like a real obstacle avoinding robot? let me know as fast as you can.

TheStudio (author)26thgenius2017-07-23

yes. once the code is uploaded from the PC to the Arduino, it will execute this code whenever it has power. This means you can connect an external battery and it will work properly on the ground like a real robot.

PS, I do not know what the situation is for using a 9V battery outside a shield, but when I built my own a few months back with a motor shield, I only had to use one power source (e.g. 9V battery) that then powered both motors and the Arduino, so it could run on itself. If you aren't using a motor shield just try any battery or battery pack to connect the USB to Arduino power cable that you use through the computer as well.

AIP06 (author)2017-07-05

hi isnt there supposed to be a motor driver module?

can you reply fast

bipul kumar gupta (author)2017-05-01

code for this project is same for windows and mac, because code run in Arduino IDE.

zhixuan (author)2017-01-23

Hi , I am beginner to Arduino. Can anyone tell me how to connect dc motors to arduino board?? use jumper wires or normal wires?? Thank you very much..

NikolaosN1 (author)2017-01-22

the 9 volt battery is connecting only at the arduino ? not at the dc motors? thanks a lot!

Yes, 9 volt battery only connected to Arduino.

Thanks a lot. I have this http://www.ebay.com/itm/172383638336?_trksid=p2060...

is the same dc motors as yours? Because something i have make wrong and i can not play...

Yes this is same motor.

NikolaosN1 made it! (author)bipul kumar gupta2017-01-23

Because it is my 1st project!!! i upload the photos of my connection. i do not understand if i make a mistake. i tried to reverse the motors also. Can you see them and propose me something please? Thanks a lot

MayankJ20 (author)2016-10-16

Can you give me the connection for battery

You can use this.

What is the material used

For Which Part??

That battery

Being Engineers (author)2016-10-12

Nicely done :)

Thanku..

ThirdEarthDesign (author)2016-10-12

Thanks for the Ible, this will come in handy for a future project.

Welcome. :)

About This Instructable

7,959views

73favorites

License:

Bio: I am an Electronics & Telecommunication Engineer, and my interest in Internet of things, Arduino, Raspberry pi, Programming, Web Designing, Robotics, Hacking, Web Security.
More by bipul kumar gupta:LED Blinking Using ArduinoObstacle Avoiding Robot Arduino
Add instructable to: