Introduction: 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
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
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
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
Here is code and the circuit design for the project.
Step 5: Complete Robot
www.bipulgupta.com
1 Person Made This Project!
- NikolaosN1 made it!
22 Discussions
3 years ago
Just a small doubt. are the two motors driven by Arduino directly and no H Bridge is required? Motors are directly connected to the Arduino pins?
Reply 3 months ago
Yes, for this project motor driver not required, you can directly connect to arduino pins.
3 years ago
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?
Reply 3 months ago
Please check your ultrasonic sensor.
Reply 3 years ago
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.
3 years ago
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.
Reply 3 months ago
you can use this
Reply 3 years ago
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.
3 years ago
hi isnt there supposed to be a motor driver module?
can you reply fast
Reply 3 months ago
For this motor driver not required.
3 years ago
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..
Reply 3 months ago
You can use this use, use PN2222 Transistor, 270 Ω Resistor, and 4001 Diode
3 years ago
code for this project is same for windows and mac, because code run in Arduino IDE.
4 years ago
Can you give me the connection for battery
Reply 4 years ago
You can use this.
Reply 4 years ago
What is the material used
Reply 4 years ago
For Which Part??
Reply 4 years ago
That battery
4 years ago
Nicely done :)
Reply 4 years ago
Thanku..