Вы находитесь на странице: 1из 5

Obstacle Avoidance Robotic Vehicle Using

Ultrasonic Sensor and Arduino Microcontroller


John Kenneth Ablay#1, Keren Jirah Pangan#2, Brando Seneca#3 Vincent Velasco#4
#
ECE Department, Eastern Visayas State University
Tacloban City, Leyte, Philippines
1kennethjohnablay@yahoo.com

2pangankenji21998@gmail.com

3senecabrando@gmail.com

4
velascovincent@gmail.com

Abstract— Obstacle avoidance and detection is one of the The Robotics Revolution. More importantly, it will have an
applications in designing mobile robots. This technology irrevocable impact on all our lives and the lives of the future.
introduces the robots with senses and tries to adapt in unfamiliar
environment with damaging itself. This project is design to build Robotics in today's world is a fast-growing and interesting
an autonomous robot that acts a stand-alone system, complete
with its own controller. An obstacle-avoiding robot is a type of
field. The robot has sufficient intelligence to cover the
autonomous mobile robot that avoids collision with unexpected maximum space available. Autonomous Intelligent Robots are
obstacles using ultrasonic sensors for its movement. This robotic robots capable of performing desired tasks in unstructured
vehicle is built, using a micro-controller of AT mega 328 families. environments without continuous human guidance. The
Using an ultrasonic sensor, any obstacle before it is detected and detection of obstacles is the primary requirement of this
a command is sent to the microcontroller. The Arduino board autonomous robot [4].
was selected as the microcontroller platform and its software Obstacle avoidance Robot is designed by avoiding
counterpart. The Arduino Software version 1.8.9 was used to collisions to navigate the robot in an unknown environment.
verify, upload or carry out the programming. This obstacle Obstacle in the path avoiding robot senses obstacle, avoiding
avoidance robot uses two drive tires are driven by two DC
motors. The integration of one ultrasonic sensor provides high
it and restarting its running. There are some very popular
accuracy in detecting obstacle by detecting or observing its robot navigation methods such as wall-following, edge
environment and the commands is Arduino program based. The detection, line-following, and much more. A more general and
hardware used in this project was easily accessed in online commonly used method for the avoidance of obstacles is
shopping platform and it is widely available and inexpensive that based on the need for the robot to stop in front of an obstacle.
makes the robot easily accessible. [1].

Keywords— Arduino microcontroller, Arduino software, obstacle


avoidance, motor shield L293d, ultrasonic sensor HC-SR04, DC II. PROJECT SPECIFICATION
Motor, servo motor This project is design to build an autonomous robot that
acts a stand-alone system, complete with its own controller.
I. INTRODUCTION
An obstacle avoiding robot is a type of autonomous mobile
The 19th century marked the acceleration of industrial robot that avoids collision with unexpected obstacles using
processes and their wide adoption of technology. The ultrasonic sensors for its movement. It is designed by avoiding
industrial revolution was at the midpoint of a swinging motion collisions to navigate the robot in an unknown environment
at the beginning of the century, and by the end we developed a
land transport automobile and were about to take the ULTRASONIC SENSOR
demonstration of powered flights. The impact on human life
was massive; social and economic rules governing travel,
health care, manufacturing, working environments, and home
life were rewritten. This repeated process continued in the
technology revolution in the twentieth century, but at a much
faster rate. There was no telephone in the early 1900s, but the
evolution of technology continues and strives to meet the
needs and wants to satisfy the people and the dawn of
millennium mobile phones was a daily sight. We are now at
the stage of a new technological shift of equal importance:
The ultrasonic sensor HC – SR04 uses sonar to determine The L2986 is a dual H – Bridge motor driver that allows
the distance of an object. It offers excellent non-contact range simultaneous speed and direction control of two DC motors.
detection in an easy-to-use package with high precision and The module can drive DC motors with voltages between 5 and
stable readings. From 2 cm to 400 cm or 1 '' to 13 feet.. 35v, with peak current
Sunlight or black material such as sharp rangefinders does not
affect its operation (although acoustically soft materials such
as cloth can be difficult to detect.

The module has two screw terminal blocks for the motor A
and B, and another screw terminal block for the ground pin,
the Vcc for the motor, and a 5v pin that can be either an input
or an output.

MATERIALS
Quantity Material
Power Supply: + 5v DC 1 Ultrasonic Sensor
Quiescent Current: <2mA 1 L298N Driver
Working Current: 15mA 1 Servo Motor
Ranging Distance: 2 cm – 400cm (1-13 ft) 1 Arduino Uno
1 Sensor Shield
SERVO MOTOR
20 Male and Female connecting wires
4 1.5V AA Battery
Servo Motor is a tiny, lightweight engine with high
output power. Servo can rotate about 180 degrees (90 in each 1 9V Battery
direction) and works just like standard types but smaller. The COSTING
researcher may use any servo code, hardware or library to Quantity Material Cost
control the servos. 1 2wd chassis kit 1,300.00
1 PVC Floor (Casing) 35.00
4 1.5 AA Battery 48.00
1 9V Battery 35.00
20 Connecting Wires 140.00
TOTAL: 1,558.00

III. DESIGN IMPLEMENTATION


FLOWCHART

Orange: Signal Red: Vcc (+) Brown: Ground (-)

L298N DRIVER
WORKING PRINCIPLE
The obstacle avoidance robot's flow chart work. It initially
checks the obstacle within 30 cm. If there is an obstacle, it The obstacle avoidance robotic vehicle uses ultrasonic
stops moving and turns left and right and checks if there is an sensors for its movements. A microcontroller of 8051 family
object closer than 30 cm. The check has two possible results, is used to achieve the desired operation. The motors are
yes or no. Yes, that means there is an object closer than 30 cm. connected through motor driver IC microcontroller.
No meaning that within 30 cm there is no object detected. If The ultrasonic sensor is attached in front of the robot.
there is nothing within 30 cm, the robot can move forward as Whenever the robot is going on the desired path the ultrasonic
the path is clear. If there is something closer than 30 cm, the sensor transmits the ultrasonic waves continuously from its
robot must avoid obstacles. sensor head. Whenever an obstacle comes ahead of it the
First the robot turns left and right, takes a reading, turns left ultrasonic waves are reflected back from an object and that
and right, and takes a reading. Another check occurs to see information is passed to the microcontroller. The
what direction is the best way to go. If left is the way to go it microcontroller controls the motors left, right, back, front
has to turn back to the left and then go forward. If right is the based on ultrasonic signals. In order to control the speed of
way to go the robot, simply moves forward as it is already each motor pulse width modulation is used (PWM).
facing in the right direction.

CIRCUIT DIAGRAM IV. PROBLEM ENCOUNTER

The wheel output does not move when the switch is turned
on. Because it is not fixed by soldering the output pins of the
said wheel. We change pin configuration from pin 8,9,10 to
pin 11,12,13. The servo motor didn't work. The servo motor
just stays stiff; it can't move any left or right direction. So we
change the configuration of the servo pin from Pin 0 to Pin 3.
The servo motor moved from the initial position to a large
degree of turn to the left. So we change the servo's position,
realizing that it is not in its correct initial center position and
we turn the entire servo motor and approximately find the
center for it to have an equal left and right turn of directions.
While making the packaging, the input for 9v supply to the
arduino board is changed due to the bulky input plug that
would hinder the packaging. We solder it directly to the board
of the arduino. After soldering the 9v input supply directly to
the arduino board. The arduino doesn't work well and is
implemented on automatic reset. So we created a switch for
the 9v battery and placed a reset button outside the Arduino
board by correcting the 9v and ground supply push button in
series and the reset pin in the arduino board. Above all, when
it didn't work well, we found the remedy for the motor and
servo problem easily. This is through the mismatch arduino
code. There is a mismatch in the arduino code and
connections to the configuration of the hardware pin. Make
sure that the pin configuration in the arduino code and the pin
configuration are connected. Hardware problems are harder to
analyse but it’s worth it.

V. CONCLUSIONS
The goal or the function of this project is to developed an
obstacle avoidance robotic vehicle using ultrasonic sensor and
arduino microcontroller.
The Arduino Software version 1.8.9 was used to verify,
upload or carry out the programming. This platform was used
for data processing and it is the software counterpart that
helped to communicate with the robot to send parameters for
guiding movement.
Ultrasonic distance sensors that provided a wider field of
//Define all the connections maps to the L298N
detection were used for obstacle detection. When the robot is
#define enA 13
placed with obstacles in the unknown environment, the robot #define in1 12
avoids the obstacle. #define in2 11
We have considerations for improvement in order to #define in3 7
#define in4 6
optimize the robot's movement. It will cost more money and
#define enB 5
time to implement the modification, however. One of the #define servoPin 2
recommendations for modification was to use a proximity
sensor attached to the back class Motor{
This project benefits us from learning more and exploring
int enablePin;
both hardware and software. It can therefore be used for int directionPin1;
educational advantages, research implementation or industrial int directionPin2;
implementation. It helped us to learn programming for
public:
microcontrollers using C++ and Arduino version 1.8.9
software platform. This helps us develop communication, //Method to define the motor pins
technical skills, creativity, and teamwork. Motor(int ENPin,int dPin1,int dPin2){
enablePin = ENPin;
ACKNOWLEDGMENT directionPin1 = dPin1;
directionPin2 = dPin2;
First and Foremost, praises and thanks to God the Almighty };
Father, for his shower of blessings throughout our research //Method to drive the motor 0~255 driving forward. -1~-255 driving
work to complete the research successfully. backward
void Drive(int speed){
To Engr. Lalaine Jean Ballais, our instructor who shared his if(speed>=0){
knowledge about this project and inspires us to finish this digitalWrite(directionPin1, LOW);
digitalWrite(directionPin2, HIGH);
project. }
else{
To the ideas shared to us by the access of internet and to the digitalWrite(directionPin1, HIGH);
authors of their books and journals. Our heartfelt gratitude to digitalWrite(directionPin2, LOW);
you all. speed = - speed;
}
analogWrite(enablePin, speed);
And lastly to our fellow ECE 4A students for their advices }
and for their constant encouragement to finish this project. };

REFERENCES Motor leftMotor = Motor(enA, in1, in2);


Motor rightMotor = Motor(enB, in3, in4);
[1] Pavithra A C and Subramanya Goutham V "Obstacle Avoidance Robot
Servo myservo; // create servo object to control a servo
Using Arduino" International Journal of Engineering Research &
Technology (IJERT) NCESC - 2018 Conference Proceedings
void motorInitiation(){
[2] Faiza Tabassum, Susmita Lopa, Muhammad Masud Tarek & Dr. Bilkis
pinMode(enA, OUTPUT);
Jamal Ferdosi "Obstacle Avoiding Robot" Global Journal Inc (USA)
pinMode(in1, OUTPUT);
Year 2017
pinMode(in2, OUTPUT);
[3] J. Grefenstette and A. Schultz. “An Evolutionary Approach to Learning
pinMode(enB, OUTPUT);
in Robots” Machine Learning Workshop on Robot Learning, New
pinMode(in3, OUTPUT);
Brunswick, 1994.
pinMode(in4, OUTPUT);
[4] R. Vairavan, S.Ajith Kumar, L.Shabin Ashiff, C. Godwin Jose
// Set initial direction and speed
“Obstacle Avoidance Robotic Vehicle using ultrasonic sensor, Arduino
digitalWrite(enA, LOW);
controller” International Research Journal of Engineering and
digitalWrite(enB, LOW);
Technology (IRJET) Volume: 05 Issue:02, Feb 2018
digitalWrite(in1, LOW);
[5] R Ismail, Z Omar, and S Suaibun “Obstacle-avoiding robot with IR and
digitalWrite(in2, HIGH);
PIR motion sensors” R Ismail et al 2016 IOP Conf. Ser.: Mater. Sci.
digitalWrite(in3, LOW);
Eng. 152 012064
digitalWrite(in4, HIGH);
[6] Vaghela Ankit1, Patel Jigar2, Vaghela Savan3 “Obstacle Avoidance
}
Robotic Vehicle Using Ultrasonic Sensor, Android And Bluetooth For
Obstacle Detection” International Research Journal of Engineering and
//Variables--------------------------------------------------------------------------
Technology (IRJET), vol. A247, pp. 29-32, 2005.
// Anything over 400 cm (23200 us pulse) is "out of range"
const unsigned int MAX_DIST = 23200;
Appendix
bool ObsticalAhead = false;
int servoPos = 90;
#include <Servo.h>
#include <NewPing.h>
enum Directions { Forward, TurnLeft, TurnRight, TurnAround,Brake};
// Pins
Directions nextStep = Forward;
#define TRIG_PIN A2
#define ECHO_PIN A3
unsigned long t1;
unsigned long t2; Serial.println("checking direction");
unsigned long pulse_width; if(ObsticalAhead ==true){
float cm; nextStep = Brake;
float inches; drive();
myservo.write(180); // tell servo to go to position in variable 'pos'
//SETUP-------------------------------------------------------------------------- delay(400); // waits 15ms for the servo to reach the position
void setup() { checkDistance();
if(ObsticalAhead ==false){//if left side is open
// The Trigger pin will tell the sensor to range find myservo.write(0); // tell servo to go to position in variable 'pos'
pinMode(TRIG_PIN, OUTPUT); delay(400); // waits 15ms for the servo to reach the position
digitalWrite(TRIG_PIN, LOW); nextStep = TurnLeft;
Serial.println("Next step is TurnLeft");
// We'll use the serial monitor to view the sensor output myservo.write(90);//reset servo position
Serial.begin(9600); delay(400);
myservo.attach(servoPin); }
motorInitiation(); else{// left is blocked, now need to look at right
Directions nextStep = Forward; myservo.write(0); // tell servo to go to position in variable 'pos'
delay(800); // waits 15ms for the servo to reach the position
} checkDistance();
if(ObsticalAhead ==false){//if right side is open
void loop() { nextStep = TurnRight;
Serial.println("Next step is TurnRight");
checkDistance(); myservo.write(90);//reset servo position
checkDirection(); delay(400);
drive(); }
} else{//right is blocked as well, need to turn around
nextStep = TurnAround;
void checkDistance(){ myservo.write(90);//reset servo position
delay(300);
// Hold the trigger pin high for at least 10 us Serial.println("Next step is TurnAround");
digitalWrite(TRIG_PIN, HIGH); }
delayMicroseconds(10); }
digitalWrite(TRIG_PIN, LOW); }
else{nextStep = Forward;}//No obstical ahead
// Wait for pulse on echo pin }
while ( digitalRead(ECHO_PIN) == 0 ); void drive(){
switch (nextStep){
// Measure how long the echo pin was held high (pulse width) case Forward:
// Note: the micros() counter will overflow after ~70 min leftMotor.Drive(255);
t1 = micros(); rightMotor.Drive(255);
while ( digitalRead(ECHO_PIN) == 1); Serial.println("Forward");
t2 = micros();
pulse_width = t2 - t1; break;
case TurnLeft:
// Calculate distance in centimeters and inches. The constants leftMotor.Drive(-255);
// are found in the datasheet, and calculated from the assumed speed rightMotor.Drive(255);
//of sound in air at sea level (~340 m/s). Serial.println(" TurnLeft");
cm = pulse_width / 58.0; delay(400);
inches = pulse_width / 148.0; break;

// Print out results case TurnRight:


if ( pulse_width > MAX_DIST ) { leftMotor.Drive(255);
//Serial.println("Out of range"); rightMotor.Drive(-255);
} else { Serial.println(" TurnRight");
//Serial.print(cm); delay(400);
//Serial.print(" cm \t"); break;
//Serial.print(inches);
//Serial.println(" in"); case TurnAround:
} leftMotor.Drive(255);
// Wait at least 60ms before next measurement rightMotor.Drive(-255);
delay(60); Serial.println(" TurnAround");
delay(650);
if(cm<= 35){ break;
ObsticalAhead = true;
Serial.println("Problem Ahead"); case Brake:
leftMotor.Drive(-150);
} rightMotor.Drive(-150);
else{ ObsticalAhead = false;} Serial.println(" stopped");
delay(220);
} }
void checkDirection(){

Вам также может понравиться