0% found this document useful (0 votes)
70 views21 pages

Obstacle Avoiding Robot Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views21 pages

Obstacle Avoiding Robot Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

OBSTACLE

AVOIDING ROBOT
 1.)Arduino Uno
HARDWARES  2.)Ultrasonic Range Finder Sensor – HC –
SR04
AND  3.)Motor Driver IC – L293D

SOFTWARES 

4.)Servo Motor (Tower Pro SG90)
5.)Geared Motors x 2
COMPONENTS  6.)Robot Chassis
 7.)Power Supply
REQUIRED  8.)Arduino IDE
 9.)C++ Programming language.
Component Description

 Arduino Uno
 Arduino Uno is an ATmega 328p
Microcontroller based prototyping
board. It is an open source
electronic prototyping platform that
can be used with various sensors
and actuators.
 Arduino Uno has 14 digital I/O pins
out of which 6 pins are used in this
project.
Component Description

 HC – SR04
 It is an Ultrasonic Range Finder Sensor.
It is a non-contact based distance
measurement system and can measure
distance of 2cm to 4m.
 L293D
Component It is a motor driver which can provide
Description bi-
two motors.
directional drive current for

 Servo Motor
The Tower Pro SG90 is a simple Servo
Motor which can rotate 90 degrees in each
direction (approximately 180 degrees
in total).
Arduino is the main processing unit of the robot. Out of the 14
available digital I/O pins, 7 pins are used in this project design.

Design of The ultrasonic sensor has 4 pins: Vcc, Trig, Echo and Gnd. Vcc
and Gnd are connected to the +5v and GND pins of the
Obstacle Arduino. Trig (Trigger) is connected to the 9th pin and Echo is
connected to 8th pin of the Arduino UNO respectively.

Avoiding A Servo Motor is used to rotate the Ultrasonic Sensor to scan


for obstacles. It has three pins namely Control, VCC and GND.
Robot using The Servo Control Pin is connected to pin 11 of Arduino while
the VCC and GND are connected to +5V and GND.
Arduino
L293D is a 16 pin IC. Pins 1 and 9 are the enable pins. These
pins are connected to +5V. Pins 2 and 7 are control inputs
from microcontroller for first motor. They are connected to
pins 6 and 7 of Arduino respectively.
Similarly, pins 10 and 15 are control inputs from
microcontroller for second motor. They are connected to
pins 5 and 4 of Arduino. Pins 4, 5, 12 and 13 of L293D are
ground pins and are connected to Gnd.

Design of First motor (consider this as the motor for left wheel) is
connected across the pins 3 and 6 of L293D. The second
Obstacle motor, which acts as the right wheel motor, is connected
to 11 and 14 pins of L293D.
Avoiding The 16th pin of L293D is Vcc1. This is connected to +5V.
Robot using The 8th pins is Vcc2. This is the motor supply voltage.
This can be connected anywhere between 4.7V and 36V.
In this project, pin 8 if L293D is connected to +5V supply.
Arduino
Motor Driver boards are available with on – board 5V
voltage regulator. A similar one is used in the project.
Before going to working of the project, it is important to
understand how the ultrasonic sensor works. The basic
principle behind the working of ultrasonic sensor is as
follows:

Using an external trigger signal, the Trig pin on ultrasonic


sensor is made logic high for at least 10µs. A sonic burst
from the transmitter module is sent. This consists of 8
pulses of 40KHz.
Working The signals return back after hitting a surface and the
receiver detects this signal. The Echo pin is high from the
time of sending the signal and receiving it. This time can
be converted to distance using appropriate calculations.

The aim of this project is to implement an obstacle


avoiding robot using ultrasonic sensor and Arduino. All the
connections are made as per the circuit diagram. The
working of the project is explained below.
When the robot is powered on, both the motors of the robot will
run normally and the robot moves forward. During this time,
the ultrasonic sensor continuously calculate the distance
between the robot and the reflective surface.

This information is processed by the Arduino. If the distance


between the robot and the obstacle is less than 15cm, the
Robot stops and scans in left and right directions for new
distance using Servo Motor and Ultrasonic Sensor.If the
WORKING distance towards the left side is more than that of the right
side, the robot will prepare for a left turn.But first, it backs up a
little bit and then activates the Left Wheel Motor in reversed in
direction.
Similarly, if the right distance is more than that of the left
distance, the Robot prepares right rotation. This process
continues forever and the robot keeps on moving without
hitting any obstacle.
 Obstacle avoiding robots can be used in
Applicatio almost all mobile robot navigation
systems.
ns  They can be used for household work like
automatic vacuum cleaning.
 They can also be used in dangerous
environments, where human penetration
could be fatal.
#include <AFMotor.h>
#include <NewPing.h>
#include <Servo.h>
#define TRIG_PIN A0

CODE #define ECHO_PIN A1


int MAX_DISTANCE =100
int MAX_SPEED= 150 // sets speed of DC motors
int MAX_SPEED_OFFSET =20

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);


AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR34_64KHZ);
AF_DCMotor motor4(4, MOTOR34_64KHZ);
Servo myservo;

boolean goesForward=false;
int distance = 100;
int speedSet = 0;

void setup() {

CODE
 myservo.attach(10);
 myservo.write(115);
 delay(2000);
 distance = readPing();
 delay(100);
 distance = readPing();
 delay(100);
 distance = readPing();
 delay(100);
 distance = readPing();
 delay(100); }

void loop() {
 int distanceR = 0;
 int distanceL = 0;
 delay(40);
 if(distance<=25)
{moveStop();

 delay(100);
 moveBackward();
 delay(200);

CODE 


moveStop();
delay(200);
 distanceR = lookRight();
 delay(200);
 distanceL = lookLeft();
 delay(200);

 if(distanceR>=distanceL)
 { turnRight();
 moveStop();}

 else
 { turnLeft();
 moveStop(); }
 }
else

 { moveForward(); }
 distance = readPing();
}

int lookRight()

CODE
{ myservo.write(50);
 delay(500);
 int distance = readPing();
 delay(100);
 myservo.write(115);
 return distance; }

int lookLeft()
{ myservo.write(170);
 delay(500);
 int distance = readPing();
 delay(100);
 myservo.write(115);
 return distance;
 delay(100); }

int readPing() {
 delay(100);
 int cm = sonar.ping_cm();
 if(cm==0){
 cm = 250; }

CODE
 return cm; }

void moveStop() {
 motor1.run(RELEASE);
 motor2.run(RELEASE);
 motor3.run(RELEASE);
 motor4.run(RELEASE); }

void moveForward() {
 if(!goesForward)
 { goesForward=true;
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
 for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to
{ motor1.setSpeed(speedSet);
 motor2.setSpeed(speedSet);
 motor3.setSpeed(speedSet);
 motor4.setSpeed(speedSet);
 delay(5); }
 } }

CODE 

void moveBackward() {
 goesForward=false;
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
 motor3.run(BACKWARD);
 motor4.run(BACKWARD);
 for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2) // slowly bring the speed up to
avoid loading down the batteries too quickly
{ motor1.setSpeed(speedSet);
 motor2.setSpeed(speedSet);
 motor3.setSpeed(speedSet);
 motor4.setSpeed(speedSet);
 delay(5);
 }
void turnRight() {
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(BACKWARD);
 motor4.run(BACKWARD);

CODE
 delay(500);
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD); }

void turnLeft() {
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
 delay(500);
 motor1.run(FORWARD);
 motor2.run(FORWARD);
 motor3.run(FORWARD);
 motor4.run(FORWARD);
www.electronicshub.org

nevonprojects.com

http://www.instructables.com/id/Arduino-Ultimate-
REFERENCES Obstacle-Avoiding-Robot/

www.instructables.com

https://tech.endeepak.com/blog/2016/01/02/simple-
obstacle-avoiding-robot-using-arduino/
Conclusion:

 The obstacle-avoiding robot successfully navigated its


environment by detecting obstacles and adjusting its path
accordingly. The output could include a summary of the robot's
performance, such as the number of obstacles detected, the
distance covered, and any challenges encountered during
testing. Additionally, you could include insights on improvements
or future developments for the robot's functionality and
efficiency.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy