Professional Documents
Culture Documents
PRAVEEN
APRIL - 8 - 2014
20 COMMENTS
A line follower robot using 8051 microcontroller is already published here and this
time the same thing is done using arduino. This line follower robot is basically designed to
follow a black line on a white surface. Any way the same project can be used to follow the
opposite configuration with appropriate changes in the software. The entire hardware of this
simple line follower robot using arduino can be divided into three parts. The sensor, arduino
board and the motor driver circuit. Lets have a look at the sensor first.
Sensor.
The sensor consists of two LED/LDR pairs with appropriate current limiting resistors. The
resistance of an LDR is inversely proportional to the intensity of the light falling on it. The
circuit diagram of the sensor is shown in the figure below.
From the above table you can see that the voltage across a particular LDR will be 4.4V when
it on white and 4.84V when it is on black. The digital equivalent of 4.4V will be 900 and that
of 4.84V will be 990 as per the above scheme. The median of these two values is 945 and it
is set as the reference point for the program to check the orientation of the sensor module.
The program identifies the position of the sensor module by comparing the sensor readings
with the reference point that is 945. If the reading of a particular sensor is greater than 945
the program can assume that the particular sensor is above black. If the reading of a
particular sensor is less than 945 then it is assumed that the particular sensor is above
white. If both sensor readings are less than 945 then it means both sensors are on white. If
both sensor readings are above 945 it is assumed that both sensors are above black (the
same thing happens if we lift the robot off the track). Based on the above four conditions,
the program appropriately switches the left and right motors to keep the robot following the
black line.
Motor driver.
The motor driver circuit is based on two NPN transistors Q1 and Q2. Each transistors are
wired as a switch with a resistor at its base for limiting the base current. The motors are
connected to the emitter terminal of the corresponding transistors. A 0.1uF capacitor is
connected across each motor for by-passing the voltage spikes. Back emf and arcing of
brushes are the main reason behind the voltage spikes. If these voltage spikes are not bypassed it may affect the Arduino side. Circuit diagram of the motor driver is shown in the
figure below.
Circuit diagram.
Full circuit diagram of the line follower robot is shown in the figure below.
Program.
int leftInput=A3;
int rightInput=A4;
int leftMotor=13;
int rightMotor=12;
int leftValue = 0;
int rightValue = 0;
void setup()
{
pinMode (leftMotor, OUTPUT);
pinMode (rightMotor, OUTPUT);
}
void loop()
{
leftValue = analogRead (leftInput);
rightValue= analogRead (rightInput);
if
( leftValue < 945 && rightValue < 945)
{
First of all remember that each LED and LDR has its own characteristics.
Carefully measure the voltage across each LDRs in both scenarios (on white surface
and black).
A lot of parameters like individual LDR/LED characteristics, ambient light, clearance
While soldering up the sensor module, the gap between the two LED/LDR pairs
must be selected according to the width of the black line. In my case it was 2cm.
Clearance of the sensor from the ground was around 1cm in my case.
The sensor LEDs used were 4mm bright green LEDs.
The sensor LDRs used were general purpose LDRs.