Sei sulla pagina 1di 12

AKHONA NTANJANA

WALL FOLLOWER ROBOT

212001698

TABLE OF CONTENT

Introduction..........................................................................................
...........3
Ultrasonic Sensor..............................................................................................................4
Motor Driver Section........................................................................................................4
Components......................................................................................................................4
Block Diagram..................................................................................................................5
Schematic Diagram...........................................................................................................5
Connection Description....................................................................................................6
Arduino Code....................................................................................................................7

LIST OF FIGURES
HC-SR04 ..........................................................................................................................5
BLOCK-DIAGRAM...........................................................................................................6
SCHEMATIC DIAGRAM .................................................................................................6
CIRCUIT CONNECTION 1...............................................................................................6

WALL FOLLOWER ROBOT


Introduction
An Wall Follower Robot may be defined as a robot which can follow any kind of wall
and is capable of changing its path according to the shape of the wall.
The basic tasks of an Wall follower Robot can be divided into 3 sections, namely
Navigation
Processing
Execution
The robot must be equipped with some means by which it can navigate its
surrounding to check the existence of a wall or the shape of the wall. In this
project Ultrasonic Sensors have used for the purpose of navigation .
After navigating the surrounding the robot must be capable of processing the input data
from the navigation section. In this project the processing section is done with an
Arduino, which comes along with the microcontroller Atmega 328P microcontroller .
While processing the robot takes decision according to the algorithm designed for it.
After processing the navigated data the robot must do some work (e.g.
Movement etc). In this project I have used motor driver IC L293D to drive the
motors/wheels according to the processed output from the Arduino.

Ultrasonic Sensor

HC-SR04

Ultrasonic sensors work on a principle similar to radar or sonar which evaluate


attributes of a target by interpreting the echoes from radio or sound waves
respectively. Ultrasonic sensors generate high frequency sound waves
and evaluate the echo which is received back by the sensor. An analog
Ultrasonic Sensor produces analog signal according to the distance from

the object.

Motor Driver Section


The motor driver section consists of IC L293D. It has 4 inputs and 4 outputs.
Since, the current from the arduino is not sufficient enough to drive the motors, so we
have to use this Driver to increase the current by which we can drive the DC Motors.

Components
The Components required for building the Wall follower Robot are:
Embedded Application Board (ARDUINO)
Motor Driver Board (containing L293D)

Ultrasonic Sensors (2 nos)

DC Motors (2 nos)
Chassis

Connectors(Jumpers)
9V battery

Wheels

Walls

Block Diagram
Block level representation of the different blocks of the Wall follower Robot.

BLOCK DIAGRAM 1

Schematic Diagram
The Schematic diagram illustrates the circuit connections for designing the application.

SCHEMATIC DIAGRAM 1

Connection Description
In this project I used 2 Ultrasonic Sensor modules as wall detectors. They are placed in
the Right and Front corner of the robot. These modules have 4-pins each, as GND, VCC,
TRIG and ECHO . The GND and VCC pins are connected to the GND and VCC pins of
the Arduino. The DATA pins (trig and echo) of the sensors are connected to pins A2, A3,
A4 AND A5 of the arduino. The inputs to the motor driver are from Pins 3, 5, 6 and 9 of
the arduino, all these pins are able to output a PWM signal. These pins are responsible for
controlling the robot and they are connected to the IN1, IN2, IN3 and IN4 pins of the
Motor Driver board, respectively. Both the Motor Driver Board and the Arduino are

powered with 9V rechargeable battery.:

CIRCUIT CONNECTION 2

Arduino Code
#define motor_l 10
#define motor_r 11
#define l1 3
#define l2 5
#define r1 6
#define r2 9
int trigger_f = A4;
int echo_f = A5;
int trigger_l = A2;
int echo_l = A3;
int trigger_r = A0;
int echo_r = A1;
void setup()
{
pinMode(trigger_f, OUTPUT);
pinMode(echo_f, INPUT);
pinMode(trigger_l, OUTPUT);
pinMode(echo_l, INPUT);
pinMode(trigger_r, OUTPUT);
pinMode(echo_r, INPUT);
pinMode(motor_l, OUTPUT);
pinMode(motor_r, OUTPUT);
pinMode(l1, OUTPUT);
pinMode(l2, OUTPUT);
pinMode(r1, OUTPUT);
pinMode(r2, OUTPUT);
delay(5000);
}
void loop()
{
long duration_f, duration_l, duration_r, right, left, front;

digitalWrite(trigger_f, LOW);
delayMicroseconds(2);
digitalWrite(trigger_f, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_f, LOW);
duration_f = pulseIn(echo_f, HIGH);
front = duration_f/29/2;
digitalWrite(trigger_l, LOW);
delayMicroseconds(2);
digitalWrite(trigger_l, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_l, LOW);
duration_l = pulseIn(echo_l, HIGH);
left = duration_l/29/2;
digitalWrite(trigger_r, LOW);
delayMicroseconds(2);
digitalWrite(trigger_r, HIGH);
delayMicroseconds(5);
digitalWrite(trigger_r, LOW);
duration_r = pulseIn(echo_r, HIGH);
right = duration_r/29/2;
analogWrite(motor_l, 0); //
analogWrite(motor_r, 0); //
analogWrite(l1, 0);
//
analogWrite(l2, 0);
//
analogWrite(r1, 0);
//
analogWrite(r2, 0);
//
if(front >8)
{
if(right >7 && right< 13)
{
analogWrite(motor_l, 120);
analogWrite(motor_r, 150);
analogWrite(l1, 255);
analogWrite(l2, 0);
analogWrite(r1, 0);
analogWrite(r2, 255);

}
if(right >=13)
{
analogWrite(motor_r, 255);
analogWrite(motor_r, 60);
analogWrite(l1, 255);
analogWrite(l2, 0);
analogWrite(r1, 0);
analogWrite(r2, 255);
}
if(right <=7)
{
analogWrite(motor_l, 60);
analogWrite(motor_r, 255);
analogWrite(l1, 255);
analogWrite(l2, 0);
analogWrite(r1, 0);
analogWrite(r2, 255);
}
}
if(left <=20 && right>20 && front <=8) rig();
if(left >20 && right>20 && front <=8) rig();
if(right <=20 && left>20 && front <=8) lef();
if(right<=20 && left<=20 && front<=8) forward();
}
void lef()
{
analogWrite(motor_l, 120);
analogWrite(motor_r, 120);
analogWrite(l1, 0);
analogWrite(l2, 255);
analogWrite(r1, 0);
analogWrite(r2, 255);

delay(700);
}
void rig()
{
analogWrite(motor_l, 120);
analogWrite(motor_r, 120);
analogWrite(l1, 255);
analogWrite(l2, 0);
analogWrite(r1, 255);
analogWrite(r2, 0);
delay(800);
}
void forward()
{
analogWrite(motor_l, 120);
analogWrite(motor_r, 120);
analogWrite(l1, 255);
analogWrite(l2, 0);
analogWrite(r1, 255);
analogWrite(r2, 0);
delay(1200);
}

Potrebbero piacerti anche