You are on page 1of 10

Line Following Robot With Color Detection

Authors : Md. Risat Abedin, Faysal Alam, Ajwad Muhtasim Dip


Department of Electrical & Electronic Engineering
Ahsanullah University of Science & Technology
Email: risat.eee@gmail.com

Abstract: A line following robot is a robot that basically  DC Power Adapter (9V,2A)
follows a specific line. This line following robot is sensor  Ball Castor
based. Sensor based approach uses various kinds of
 7805 IC
sensors such as IR sensors and ultrasonic sensors. IR
sensors are generally used for measuring the difference  L293D IC
in reflectivity of surfaces depending on the properties  Breadboard & Jumper wires
like color, roughness etc. Which is this line follower is
based on. The path can be visible like a black line on
a white surface (or vice-versa). Sensing a line and Project Development & Background
maneuvering the robot to stay on course, while
constantly correcting wrong moves using feedback
mechanism forms a simple yet effective closed loop We researched a little bit to select our hardware and
system. This bot was developed based on a vision based
preferable methods to accomplish this task. We
system to navigate the robot through a black line
marked in the white surface. It also extracted some
selected our preferences based on availability and
features in the sensor to follow a line with automatic price range to build this robot.
color detection and follow that color in white surface.
This report is intended to describe the information
regarding the project. It explains the requirements, the Microcontroller:
techniques and technologies used, design and
implementation, details, problems faced, and future
improvements of the project. Microcontrollers are the preferred method for
Keywords : Line follower, Microcontroller , Color
endowing a robot with smarts. The reasons for this
detector , IR sensor .
include their low costs, simple power requirements
Introduction
(usually 5 to 9 V), and ability of most, to be
programmed using software and a simple hardware
Robotics has greatly advanced in the developed interface on the PC. Once programmed, the
countries. High performance, high accuracy, lower microcontroller is disconnected from the PC and
labor cost and the ability to work in hazardous operates on its own. These are programmed either in
places have put robotics in an advantageous an assembly language or in a high level language
position over many other such technologies But as such as C or C++.Here we use Arduino UNO R3.
for developing countries like Bangladesh it is still The Arduino Uno is a microcontroller board based on
quite out of reach. But it is one of the most the ATmega328. It has 14 digital input/output pins
fascinating and interesting aspects to the new (of which 6 can be used as PWM outputs), 6 analog
generations and a lot of development in robotics has inputs, a 16 MHz ceramic resonator, a USB
been done in last couple of years. On this note is this connection, a power jack, an ICSP header, and a reset
effort to make a relatively cheap line follower button. It contains everything needed to support the
microcontroller; simply connect it to a computer with
Equipment List a USB cable or power it with a AC-to-DC adapter or
battery to get started. The ATmega328 on the
Arduino Uno comes preburned with a bootloader that
 Arduino Uno R3. allows you to upload new code to it without the use
 Photoresistor. of an external hardware programmer. Besides it is
 IR Transmitter. cheap and almost available in electronics hardware
 DC Gear Motor with Wheels. stores.
divider varies with the intensity of IR light we have
used analog arduino input to measure the results to

make the sensor take the readings.

The values of the resistors are calibrated for better


reading differences. These voltage differences
readings are analog readings. Ardunio has built in
ADC which it converts to Digital.

Sensor Circuit:

For Sensor Circuit we have used a pair of IR Sensors.


One is IR LED i.e. transmitter another is an IR
Sensor i.e. photoreciever. The basic principle of IR
sensor is based on an IR emitter and an IR
receiver. IR emitter will emit infrared continuously
when power is supplied to it. On the other hand, the
IR receiver will be connected and perform the
task of a voltage divider. IR receiver can be
imagined as a transistor with its base current
determined by the intensity of IR light received.
The lower the intensity of IR light cause higher When the IR emitter falls on a white surface it gets
resistance between collector-emitter terminals of
transistor, and limiting current from collector to reflected and the IR receiver receives the full IR
emiiter. This change of resistance will further intensity thus lower resistance between emitter and
change the voltage at the output of voltage collector terminal causing flowing of current and
divider. In others word, the greater the intensity resulting a larger voltage. But when it falls on a black
of IR light hitting IR receiver, the lower the or similar surface IR is absorbed and the receiver
resistance of IR receiver and hence the output receives a lot less IR resulting increase of resistance
voltage of voltage divider will decreased. Usually
between the emitter and collector terminal causing
the IR emitter and IR receiver will be mounted side
by side. Since the output voltage from voltage limiting of current thus the output voltage. These
divider varies with the intensity of IR light pointing voltage changes are ranged between (1-1024) as the
to a reflective surface. The further distance away analog outputs of arduino are 10 bit resolutions. We
between emitter and receiver decrease the amount differentiated the analog values in order to get our
of infrared light hitting the receiver if the required results
distance between the sensor and a reflective surface
is fixed. Since the output voltage from voltage
We have used 3 sensors in an array for the line
detection. The middle sensor will always read black 1. Turning on Switches A and D makes the
while the other two will read white surface. And it is motor rotate clockwise
programmed to move or rotate on basis of readings 2. Turning on Switches B and C makes the
that it is getting from the readings from the sensor motor rotate anti-clockwise
array. 3. Turning on Switches A and B will stop the
motor (Brakes)
IC L293D : 4. Turning off all the switches gives the motor
a free wheel drive
The most common method to drive DC motors in two 5. Lastly turning on A & C at the same time
directions under control of a computer is with an H- or B & D at the same time shorts your entire
bridge motor driver. H-bridges can be built from circuit. So, do not attempt this.
scratch with bi-polar junction transistors (BJT) or
with field effect transistors (FET), or can be
purchased as an integrated unit in a single integrated L293D IC generally comes as a standard 16-pin DIP
circuit package such as the L293. The L293 is (dual-in line package). This motor driver IC can
simplest and inexpensive for low current motors, For simultaneously control two small motors in either
high current motors, it is less expensive to build your direction; forward and reverse with just 4
own H-bridge from scratch. Motor driver is basically microcontroller pins.
a current amplifier which takes a low-current signal
from the microcontroller and gives out a
proportionally higher current signal which can
control and drive a motor. In most cases, a transistor
can act as a switch and perform this task which drives
the motor in a single direction. Turning a motor ON
and OFF requires only one switch to control a single
motor in a single direction. But by reversing its
polarity motor control in both direction is achievable.
This can be achieved by using four switches that are
arranged in an intelligent manner such that the circuit
not only drives the motor, but also controls its
direction. Out of many, one of the most common and
clever design is a H-bridge circuit where transistors
are arranged in a shape that resembles the English
alphabet "H".

The circuit has four switches A, B, C and D. Turning


these switches ON and OFF can drive a motor in
different ways.
to function. If they pulled low (GND), then
the outputs will be turned off regardless of
the input states, stopping the motors. If you
have two spare pins in your microcontroller,
connect these pins to the microcontroller, or
just connect them to regulated positive 5
Volts.
2. Pin4, Pin5, Pin12 and Pin13 are ground pins
which should ideally be connected to
microcontroller's ground.
3. Pin2, Pin7, Pin10 and Pin15 are logic input
pins. These are control pins which should be
connected to microcontroller pins. Pin2 and
Pin7 control the first motor (left); Pin10 and
Pin15 control the second motor(right).
4. Pin3, Pin6, Pin11, and Pin14 are output pins.
Tie Pin3 and Pin6 to the first motor, Pin11
and Pin14 to second motor
Connections:
5. Pin16 powers the IC and it should be
The circuit shown to the right is the most basic connected to regulated +5Volts
implementation of L293D IC. There are 16 pins 6. Pin8 powers the two motors and should be
sticking out of this IC and we have to understand the connected to positive lead of a secondary
functionality of each pin before implementing this in battery. As per the datasheet, supply voltage
a circuit. can be as high as 36 Volts.

Truth Table :

Pin 1 Pin 2 Pin 7 Function


High High Low Turn Anti-clockwise (Reverse)
High Low High Turn clockwise (Forward)
High High High Stop
High Low Low Stop
Low X X Stop

High ~+5V, Low ~0V, X=either high or low.

DC Motor with Wheels & Ball Caster:

Motor Specifications
Operating voltage: 3V ~ 6V DC (recommended
value 5V)
Maximum torque: 800g.cm
Speed without load: 90±10rpm
1. Pin1 and Pin9 are "Enable" pins. They Reduction ratio: 1:48
should be connected to +5V for the drivers
No Load current: 190mA (max.250mA) 1 1 1 Stop
Stall Current: ~1A

Working Procedure

With the supply from an 9V DC power adapter the


whole sensor and the motor driver IC and the motors
and arduino are powered. Making the setup less
prone to power failures. With the help of IC7805 a
regulate 5V is supplied to the sensor circuits and
same 5V is supplied to the enables of motor driver IC
L293D. The outputs of the sensor circuits are
connected as in the analog inputs of the arduino
board. The motor driver IC inputs are taken from four
arduino digital PWM pins and the outputs are
connected to the motors. Taking analog based (1-
1024) readings from the sensors the arduino is
programmed to control the motor based on the
readings.

Line following Algorithm:

If we give the analog readings of sensor into some


digitalized values, then
For White surface, Sensor reading =1
For Black surface, Sensor reading =0
Right Mid Left Motor
Sensor Sensor Sensor Command
1 0 1 Forward
1 0 0 Left
0 0 1 Right
One problem we had was mismatch of two motor
speeds with was controlled by PWM pulses to control
Color Detection: the speed of two motors in same range. We had a
problem in power distribution as typical 9V battery
This line follower is programmed to follow any color
could not supply for our robot. We switched to a
line within a white surface, provided it not same as
9V,500mA DC power adapter which solved the
white color. Which means while it is following a
problem but for a better performance and range we
black line and there is another colored line to
finally opted a 9V,2A adapter for this robot. Our
follow. It will also follow that track differentiating
sensor reading was not according to a standard where
white surface and that color surface. This was simply
we could tell the robot to detect color. So we had to
done by managing the range of analog readings under
acquire a better lead coated IR sensor pairs for large
various colors.
regions of data. Our Ball caster was kind of stiff so
we had to make sure it does not hamper the smooth
movement of the robot. Lastly we had to reduce the
weight of the chassis so that it can move faster.

Possible Improvements:
Applications
-Use of differential steering with gradual change in
This line following robotics has various types of wheel speeds.
applications in both home and industrial sectors.
-Use of Hysteresis in sensor circuit using LM339

-Use of PD Controlled codes to the movement of the


o Industrial Applications: These robots can robot.
be used as automated equipment carriers in
industries replacing traditional conveyer
belts.
o Automobile applications: These robots can
also be used as automatic cars running on
roads with embedded magnets.
o Domestic applications: These can also be
used at homes for domestic purposes like
floor cleaning etc.
o Guidance applications: These can be used
in public places like shopping malls,
museums etc to provide path guidance.

Besides there will be much more applications which


we do not know now but can be done this type of
robots.

-Use of Four wheels drive to reduce traction of ball


caster and for better turning.
Troubleshooting
-General improvements like using a low dropout
The road towards making this robot was not a smooth voltage regulator, lighter chassis etc.
one. We faced various problems each day and at each
single aspects and had to troubleshoot it one by one.
-Using stepper motors instead of the DC motors
would have improved control.

Conclusion

The line following robot project challenged the group


to cooperate, communicate, and expand
understanding of electronics, mechanical systems,
and their integration with programming. This project
would not have been successful without every
member of the group contributing and
communicating during the problem-solving process,
and without the knowledge and advice of Mr.
HAMID. Overall, the line following robot was an
incredible learning opportunity for everyone
involved.

Block Diagram of the


Project

Circuit Diagram: (Final)

Final Design:
int rightsen = A0;
int midsen = A1;
int leftsen = A2;
int lmf = 10;
int lmr = 9;
int rmf = 11;
int rmr = 6;

int ledpin = 5;

void setup()
{ Serial.begin(9600);
pinMode(lmf, OUTPUT);
pinMode(lmr, OUTPUT);
pinMode(rmf, OUTPUT);
pinMode(rmr, OUTPUT);
}

void loop()
Sensor Circuit:
{ analogWrite(ledpin, 255);
int rightread = analogRead(rightsen);
int midread = analogRead(midsen);
int leftread = analogRead(leftsen);
Serial.print("Right Sensor :");
Serial.println(rightread);
Serial.print("Mid Sensor :");
Serial.println(midread);
Serial.print("Left Sensor :");
Serial.println(leftread);

if
((rightread>400)&&(midread<=400)&&(leftread>40
Motor Diver IC L293D: 0)) forward();
else if
((rightread<=400)&&(midread<=400)&&(leftread>4
00)) right();
else if
((rightread>400)&&(midread<=400)&&(leftread<=6
00)) left();
else halt();
}

void forward()
{ analogWrite(lmf, 80);
analogWrite(rmf, 100);
}

void left()
{ analogWrite(lmf, 0);
analogWrite(rmf, 255);
}

Line Following Code: void right()


{ analogWrite(lmf, 255);
analogWrite(rmf, 0); [11]
} http://www.patrickmccabemakes.com/PatrickMccabe
Makes/Mazev3.html
void halt()
{ analogWrite(lmf, 0); [12] http://www.richardvannoy.info/line-maze-part-
analogWrite(rmf, 0);
05.php#5-4
}
[13]
void reverse()
{ analogWrite(lmr, 150); http://www.electronicsforu.com/electronicsforu/circu
analogWrite(rmr, 200); itarchives/view_article.asp?sno=491&title%20=%20
} Automated+Line+Following+Robot&id=4679&articl
e_type=2&b_type=new&ss=%20398812

[14] http://linefollower-robot.blogspot.com/
Refernce
[15] http://www.instructables.com/id/Arduino-and-
[1] http://robotsreloaded.blogspot.com/p/line- L293D-Robot-Part-1-/?ALLSTEPS
following-robot-without.html
[16] http://www.richardvannoy.info/my-line-
[2] http://www.roboticsbible.com/simple-line- follower.php
following-robot.html
[17] http://embedjournal.com/2013/06/line-follower-
[3] robot/
http://abhitechstrong.blogspot.com/2013/01/robotics-
project-1-making-line-follower.html [18] http://www.tinkerhobby.com/motion-and-light-
sensors-with-arduino-and-without/
[4 ]http://legendtronics.blogspot.com/2013/10/line-
follower-robot-with-and-without.html [19 http://extremeelectronics.co.in/robotics/making-
a-line-sensor-using-ir-receiver/
[5] http://www.elprocus.com/line-follower-robot-
basics-controlling/ [20] http://www.buildcircuit.com/test-your-sensors-
for-line-following-robots/
[6] http://embedded-
electronics.blogspot.com/2013/06/line-follower- [21] http://tetalab.org/blog/23
robot-without.html
[22] https://www.inkling.com/read/arduino-
[7] http://circuit-diagram.hqew.net/Analog-Line- cookbook-michael-margolis-2nd/chapter-8/recipe-8-
Follower-Robot_11907.html 11

[8] [23] http://garagelab.com/profiles/blogs/tutorial-


http://letslearnelectronics.blogspot.com/2012/08/mak l293d-h-bridge-dc-motor-controller-with-arduino
e-line-follower-robot-from-basics.html
[24
[9] ]http://www.robotplatform.com/howto/L293/motor_d
http://letslearnelectronics.blogspot.in/2012/06/playin river_1.html
g-with-sensors-making-decision.html
[25 ]http://42bots.com/competitions/arduino-line-
[10] http://www.techshopbd.com/tutorial- following-code-video/
categories/robotics/line-following-robot
[26]
http://www.societyofrobots.com/schematics_infrared
emitdet.shtml
[27] https://gist.github.com/whyisjake/2354277

You might also like