OBSTACLE AVOIDING ROBOT USING 3 ULTRASONIC SENSOR

by Suvikram Pradhan in Circuits > Robots

5035 Views, 2 Favorites, 0 Comments

OBSTACLE AVOIDING ROBOT USING 3 ULTRASONIC SENSOR

3.PNG
4.PNG
This undertaking depicts about a obstacle evasion robot vehicle that is constrained by ultrasonic sensor. The robot prototype vehicle is controlled by Arduino microcontroller and uses ultrasonic sensor for obstacle detection. This sensor is fixed in front bit as well as two sides of this vehicle. The sensor gets the data starting enveloping zone through connected sensors on the robot. The sensor senses the obstacle and go in its approach to pick an impediment free way. The sensor will send the instruction to the controller and is stood out from controller with pick the right motion to the robot wheel. The vehicle wheel now advancement and heading will be established on the identifying of the ultrasonic sensor and besides using a wheel encoder. This vehicle is used for perceiving obstruction and avoiding the effect.

OBSTACLE AVOIDING ROBOT USING 3 ULTRASONIC SENSORS

THE MAJOR COMPONENTS REQUIRED FOR THIS ROBOT IS :
ARDUINO UNO
3 ULTRASONIC SENSORS
BATTERY
CHASSIS
MOTORS
WHEELS
GLUE GUN
SOLDERING
IRON MOTOR
DRIVER JUMPERS

Assemble All the Components on the Desired Chassis Using Nuts and Bolts

2.PNG

The first and the most important step is to make the chassis ready using proper nuts and bolts and the desired components.

Make Proper Connections From Various Sensors to the Arduino.

1.PNG

trigPin1 = 8;

echoPin1 = 9;

trigPin2 = 10;

echoPin2 = 11;

trigPin3 = 12;

echoPin3 = 13;

in1 = 3;

in2 = 4;

in3 = 5;

in4 = 6;

where trig refers to the trigger pin of the ultrasonic sensor and echo refers to echo pin.

1 -> front

2-> left

3-> right

in1 ; in2 ; in3 ; in4 refers to the input pins of the motor driver.

RECHECK ALL THE CONNECTIONS

In this steps re check all the connections are done properly or not and also check the power connections using a multimeter .

The power input to the arduino will be in between 5 to 12 volts and not more than that.

COMPILE THE GIVEN CODE

const int trigPin1 = 8;

const int echoPin1 = 9;

const int trigPin2 = 10;

const int echoPin2 = 11;

const int trigPin3 = 12;

const int echoPin3 = 13;

const int in1 = 3;

const int in2 = 4;

const int in3 = 5;

const int in4 = 6;

void setup()

{

pinMode(trigPin1, OUTPUT);

pinMode(echoPin1, INPUT);

pinMode(trigPin2, OUTPUT);

pinMode(echoPin2, INPUT);

pinMode(trigPin3, OUTPUT);

pinMode(echoPin3, INPUT);

pinMode (in1, OUTPUT);

pinMode (in2, OUTPUT);

pinMode (in3, OUTPUT);

pinMode (in4, OUTPUT);

}

long duration1, distance1;

long duration3, distance3;

long duration2, distance2;

void loop()

{

digitalWrite(trigPin1, LOW);

delayMicroseconds(2);

digitalWrite(trigPin1, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin1, LOW);

duration1 = pulseIn(echoPin1, HIGH);

distance1 = duration1/58.2;

if(distance1<30)

{

digitalWrite(trigPin2, LOW);

delayMicroseconds(2);

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin2, LOW);

duration2 = pulseIn(echoPin2, HIGH);

distance2 = duration2/58.2;

digitalWrite(trigPin3, LOW);

delayMicroseconds(2);

digitalWrite(trigPin3, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin3, LOW);

duration3 = pulseIn(echoPin3, HIGH);

distance3 = duration3/58.2;

if(distance3>distance2)

{

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

digitalWrite(in3, LOW);

digitalWrite(in4, LOW);

}

else

{

digitalWrite(in1, LOW);

digitalWrite(in2, LOW);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

}

}

else

{

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

}

delay(0);

}

void right_hc()

{

digitalWrite(trigPin2, LOW);

delayMicroseconds(2);

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin2, LOW);

duration2 = pulseIn(echoPin2, HIGH);

distance2 = duration2/58.2;

}

void left_hc()

{

digitalWrite(trigPin3, LOW);

delayMicroseconds(2);

digitalWrite(trigPin3, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin3, LOW);

duration3 = pulseIn(echoPin3, HIGH);

distance3 = duration3/58.2;

}

Downloads

UPLOAD THE CODE TO ARDUINO

Capture.PNG

Now upload the code to arduino microcontroller without giving any external power to arduino using a usb cable.

Remove the USB Cable and Check the Power Supply.

In this step the robot is ready to function.

READY FOR OPERATION