Obstacle Avoiding Robot using Arduino and Ultrasonic Sensor
A simple project on Obstacle Avoiding Robot is meant here. Robotics is a stimulating and fast growing field. Being a branch of engineering, the applications of robotics are increasing with the advancement of technology.The concept of Mobile Robot is fast evolving and therefore the number of mobile robots and their complexities are increasing with different applications.There are many kind of mobile robot navigation techniques like path planning, self – localization and map interpreting. An Obstacle Avoiding Robot may be a sort of autonomous mobile robot that avoids collision with unexpected obstacles.
In this project, an Obstacle Avoiding Robot is supposed. It's an Arduino based robot that uses Ultrasonic range finder sensors to avoid collisions.
Components Required
- Arduino NANO or Uno 🛒
- HC-SR04 Ultrasonic Sensor 🛒
- LM298N Motor Driver Module 🛒
- 5V DC Motors 🛒
- Battery 🛒
- Wheels 🛒
- Chassis 🛒
- Jumper Wires 🛒
Circuit Diagram
Design of Obstacle Avoiding Robot using Arduino
Arduino is that the main processing unit of the robot. Out of the 14 available digital I/O pins, 7 pins are utilized in this project design.The ultrasonic sensor has 4 pins: Vcc, Trig, Echo and Gnd. Vcc and Gnd are connected to the +5v and GND pins of the Arduino. Trig (Trigger) is connected to the 9th pin and Echo is connected to 8th pin of the Arduino UNO respectively.A Servo Motor is used to rotate the Ultrasonic Sensor to scan for obstacles. it's three pins namely Control, VCC and GND. The Servo Control Pin is connected to pin 11 of Arduino while the VCC and GND are connected to +5V and GND. L293D may be a 16 pin IC. Pins 1 and 9 are the enable pins. These pins are connected to +5V. Pins 2 and seven are control inputs from microcontroller for first motor. they're connected to pins 6 and seven of Arduino respectively.Similarly, pins 10 and 15 are control inputs from microcontroller for second motor. they're connected to pins 5 and 4 of Arduino. Pins 4, 5, 12 and 13 of L293D are ground pins and are connected to Gnd.First motor (consider this because the motor for left wheel) is connected across the pins 3 and 6 of L293D. The second motor, which acts because the right wheel motor, is connected to 11 and 14 pins of L293D.The 16th pin of L293D is Vcc1. this is often connected to +5V. The 8th pins is Vcc2. this is often the motor supply voltage. this will be connected anywhere between 4.7V and 36V. during this project, pin 8 if L293D is connected to +5V supply.
NOTE: the facility supply to the Motor Driver i.e. Pins 1 (enable 1), 8 (VCC2), 9 (enable 2) and 16 (VCC1) should tend a seperate power supply.
Motor Driver boards are available with on – board 5V transformer . an identical one is employed within the project.
How Ultrasonic Sensor are often used to Avoid Obstacles
Before getting to working of the project, it's important to know how the ultrasonic sensor works. the essential principle behind the working of ultrasonic sensor because this sensor will have important role in detecting obstacle. The fundamental principle behind the working of ultrasonic sensor is discovered as the time taken by sensor to transmit ultrasonic beams and receiving the ultrasonic beams after striking the surface. Then further the space or dis is calculated using the formula. In this project, the commonly available HC-SR04 Ultrasonic Sensor is used. To use this sensor, similar approach are going to be followed explained above.
So, the Trig pin of HC-SR04 is formed high for a minimum of 10 us. A sonic beam is transmitted with the 8 pulses of 40 KHz each.
So, the Trig pin of HC-SR04 is formed high for a minimum of 10 us. A sonic beam is transmitted with the 8 pulses of 40 KHz each.
Code:
/* Obstacle Avoiding Robot Using Ultrasonic Sensor and Arduino */
int trigPin = 9; // trig pin of HC-SR04
int echoPin = 10; // Echo pin of HC-SR04 int revleft4 = 4; //reverse motion of Left motor
int fwdleft5 = 5; //forward motion of Left motor
int revright6 = 6; //reverse motion of Right motor
int fwdright7 = 7; //forward motion of Right motor long duration, distance; void setup() {
delay(random(500,2000)); // delay for random time
Serial.begin(9600);
pinMode(revleft4, OUTPUT); // set Motor pins as output
pinMode(fwdleft5, OUTPUT);
pinMode(revright6, OUTPUT);
pinMode(fwdright7, OUTPUT);
pinMode(trigPin, OUTPUT); // set trig pin as output
pinMode(echoPin, INPUT); //set echo pin as input to capture reflected waves
} void loop() { digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // send waves for 10 us
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH); // receive reflected waves
distance = duration / 58.2; // convert to distance or length in appropriate unit distance
delay(10);
// If you don't get proper movements of your robot then change or alter the pin numbers
if (distance > 19)
{
digitalWrite(fwdright7, HIGH); // move forward
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, HIGH);
digitalWrite(revleft4, LOW);
} if (distance < 18)
{
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(500);
digitalWrite(fwdright7, LOW); //move backward
digitalWrite(revright6, HIGH);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, HIGH);
delay(500);
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(100);
digitalWrite(fwdright7, HIGH);
digitalWrite(revright6, LOW);
digitalWrite(revleft4, LOW);
digitalWrite(fwdleft5, LOW);
delay(500);
} } //code END Hope you would have liked this Project!!
Applications:
Obstacle avoiding robots are often utilized in most mobile robot navigation systems.
They can be used for household work like automatic vacuum cleaning and many other.
They can even be utilized in dangerous environments, where human penetration might be fatal.
Hope you would have liked this Project!!
Comments
Post a Comment
If you have any doubts ,Please let me know.