How to Make a Obstacle Avoiding Robot
How to Make a Obstacle Avoiding Robot:
Robotics is an interesting and fast growing field of engineering, the applications of robotics are increasing with the advancement of technology.In this tutorial we will make a simple robot.That is a obstacle avoiding robot.it can avoid any type of object.It is an Arduino based robot that uses Ultrasonic range finder sensors to avoid collisions.
Photo:(Electronics Hub):
- Arduino uno R3
- Ultrasonic sensor
- Motor Driver - L293D
- Gear Motor x 2
- Wheel x 2
- Robot Chassic
- 9V Battery
- Battery connector jack
- Battery Cap
- Male to Male Jumper Wire
- Male to Female Jumper Wire
How does it work:
In this robot,we have used a ultrasonic sensor which works with ultrasonic sound.Here in this sensor their are two different sensor.Ones is transmitter sensor and another is receiver sensor.Transmitter sensor always emit a ultrasonic sound when a objects come in front of this sensor.It will reflect the ultrasonic sound and the receiver receive the signal and arduino take this signal to perform a work which is preloaded.
How to upload program on arduino:
Code:
Arduino Program:
/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 8
Trig to Arduino pin 9*/
#define echopin 8 // echo pin
#define trigpin 9 // Trigger pin
int maximumRange = 30;
long duration, distance;
void setup() {
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT );
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (13, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
}
void loop ()
{
{
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
duration=pulseIn (echopin,HIGH);
distance= duration/58.2;
delay (50);
Serial.println(distance);
}
if (distance >= 30 ){
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay (200);
}
else if (distance >=15 && distance <= 25) {
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,LOW);
delay (1000);
}
else if (distance < 15){
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6,HIGH);
digitalWrite (7,HIGH);
delay (1000);
digitalWrite (4,LOW);
digitalWrite (5,HIGH);
digitalWrite (6,LOW);
digitalWrite (7, LOW);
delay (1000);
}
}
How to upload program on arduino:
Arduino Program:
/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 8
Trig to Arduino pin 9*/
#define echopin 8 // echo pin
#define trigpin 9 // Trigger pin
int maximumRange = 30;
long duration, distance;
void setup() {
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT );
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (13, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
}
void loop ()
{
{
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
duration=pulseIn (echopin,HIGH);
distance= duration/58.2;
delay (50);
Serial.println(distance);
}
if (distance >= 30 ){
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay (200);
}
else if (distance >=15 && distance <= 25) {
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,LOW);
delay (1000);
}
else if (distance < 15){
digitalWrite (4, LOW);
digitalWrite (5, LOW);
digitalWrite (6,HIGH);
digitalWrite (7,HIGH);
delay (1000);
digitalWrite (4,LOW);
digitalWrite (5,HIGH);
digitalWrite (6,LOW);
digitalWrite (7, LOW);
delay (1000);
}
}
No comments