Line Follower Robo Lab
Line Follower Robo Lab
Internship Report
Submitted by
Suhas P J 1MJ22CS182
Hemanth J N 1MJ22AS011
Department of ECE
of
Bachelor of Engineering
In
Artificial Intelligence and Machine Learning & Information Science
2023-24
ACKNOWLEDGEMENT
Our sincere thanks to Dr. Sajithra Varun S, Assistant Professor and Head of
Electronics and Communication Engineering, MVJCE for her support and
encouragement.
The robot uses IR sensors to sense the line, an array of 2 IR LEDs and
sensors, facing the ground have been used in this setup. An IR sensor can be
fitted near the patient's bed to which connection has been made with the robot
too. The switch for it can be activated by the supply person in the microcontroller
itself. If the switch is pressed then a flag bit is set in the microcontroller, from
which the robot follows the line and reaches near the patient and provide the
medicine to the patient. A proximity sensor can be attached with the robot so that
it detects any obstack present in their way and can alarm.
The ability to get someone around the clock is the best thing that this system
can do. This helps and simplifies the job of material supply and also reduces the
manual routine work done by the hospital staff. This technology focuses on the
delivery of safe, timely, efficient, effective, patient-centred health care. It can be
used industrial automated equipment carriers, small household applications, tour
guides in museums and other similar applications, etc.
Capturing the line position with optical sensors mounted at the front end
of the robot. Most are using several numbers of photo-reflectors, and
some leading contestants using an image sensor for image processing.
Therefore, the line sensing process requires high resolution and high
robustness.
2.
Steering the robot to track the line with any steering mechanism. This is
just a servo operation; actually, any phase compensation will be required
to stabilize tracking motion by applying digital PID filter or any other servo
algorithm.
3.
Controlling the speed according to the lane condition. The speed is
limited during passing a curve due to the friction of the tire and the floor.
Better mechanisms, therefore, can improve the power of manoeuvre. The
speed of the robot, hence, can be increased. Consequently, the robot's
performance can be increased, too.
Sign
Working of a Line Follower Robot
As stated earlier, line follower robot (LFR) follows a line, and in order to follow
a line, robot must detect the line first. Now the question is how to implement the
line sensing mechanism in a LFR. We all know that the reflection of light on the
white surface is maximum and minimum on the black surface because the black
surface absorbs maximum amount of light. So, we are going to use this property
of light to detect the line. To detect light, either LDR (light-dependent resistor) or
an IR sensor can be used. For this project, we are going with the IR sensor
because of its higher accuracy. To detect the line, we place two IR sensors one on
the left and other on the right side of the robot as marked in the diagram below.
We then place the robot on the line such that the line lies in the middle of both
sensors. We have covered a detailed Arduino IR sensor tutorial which you can
check to learn more about the working of IR sensors with Arduino Uno.
Moving Forward:
In this case, when both the sensors are on a white surface and the line is between
the two sensors, the robot should move forward, i.e., both the motors should
rotate such that the robot moves in forward direction (actually both the motors
should rotate in the opposite direction due to the placement of motors in our
setup. But for the sake of simplicity, we will call the motors rotating forward.)
Turning LEFT:
In this case, the left sensor is on top of the dark line, whereas the right sensor is
on the white part, hence the left sensor detects the black line and gives a signal,
to the microcontroller. Since, signal comes from the left sensor, the robot should
turn to the left direction. Therefore, the left motor rotates backwards and the right
motor rotates in forward direction. Thus, the robot turns towards left side.
Turning RIGHT:
This case is similar to the left case, but in this situation only the right sensor
detects the line which means that the robot should turn in the right direction. To
turn the robot towards the right direction, the left motor rotates forward and the
right motor rotates backwards and as a result, the robot turns towards the right
direction.
Stopping:
In this case, both the sensors are on top of the line and they can detect the black
line simultaneously, the microcontroller is fed to consider this situation as a
process for halt. Hence, both the motors are stopped, which causes the robot to
stop moving.
The reason to use a motor driver here is because the output signal of an Arduino
is not sufficient to drive the motor, furthermore, we need to rotate the motors in
both directions, therefore we use a motor driver to drive the motor as required
and also the motor driver is able to supply sufficient current to drive the motor.
Here, we are using a L293D motor driver which is a dual h bridge motor driver
and is sufficient for our 2 motors.
5. BO motor - 2 Nos
9. Wires
10. Screw
Circuit Diagram and Assembling the Arduino based Line Follower Robot
The circuit consists of mainly four parts: Two IR sensors, one motor drive, two
motors, one Arduino, a battery and few connecting wires. The sensor senses the
IR light reflected from the surface and feeds the output to the onboard op-amp
comparator. When the sensor is situated over the white background, the light
emitted by the sensor is reflected by the white ground and is received by the
receiver. But when the sensor is above the black background, the light from the
source doesn’t reflect to it. The sensor senses the intensity of reflected light to
give an output. The sensor’s output is fed to the microcontroller, which gives
commands to the motor driver to drive the motor accordingly. In our project, the
Arduino Uno is programmed to make the robot move forward, turn right or turn
left and stop according to the input coming from the sensor. The output of the
Arduino is fed to the motor driver.
As stated earlier, line follower robot (LFR) follows a line, and in order to follow
a line, robot must detect the line first. Now the question is how to implement the
line sensing mechanism in a LFR. We all know that the reflection of light on the
white surface is maximum and minimum on the black surface because the black
surface absorbs maximum amount of light. So, we are going to use this property
of light to detect the line. To detect light, either LDR (light-dependent resistor) or
an IR sensor can be used. For this project, we are going with the IR sensor
because of its higher accuracy. To detect the line, we place two IR sensors one on
the left and other on the right side of the robot as marked in the diagram below.
We then place the robot on the line such that the line lies in the middle of both
sensors. We have covered a detailed Arduino IR sensor tutorial which you can
check to learn more about the working of IR sensors with Arduino Uno.
The reason to use a motor driver here is because the output signal of an Arduino
is not sufficient to drive the motor, furthermore, we need to rotate the motors in
both directions, therefore we use a motor driver to drive the motor as required
and also the motor driver is able to supply sufficient current to drive the motor.
Here, we are using a L293D motor driver which is a dual h bridge motor driver
and is sufficient for our 2 motors.
The L293D has 16 pins, the pinout of L293D is shown in the below diagram.
Pin number 1 and 9 are the enable pins, we connect these two pins to a 5v input
to enable the motor.
Pin number 1A, 2A, 3A, and 4A are the control pins.
For eg. The motor will turn to the right if the pin 1A goes low and 2A goes high,
and the motor will turn to the left if 1A goes low and 2A high. So, we connect
these pins to the output pins of the decoder.
Pins 1Y, 2Y, 3Y, and 4Y are the motor connection pins.
Note: Vcc2 is the motor driving voltage pin, and only used if you are using a
high voltage motor.
Pin connection of Arduino Uno with the Motor driver are as follows:
Here, we are using a 7.4 li-ion battery to power the whole circuit. You can use
any battery type from 6-12 volt. To move the robot, we need to use motors with
low RPM but torque high enough to carry the weight of the robot. So, I chose
two 60 RPM 6V Battery Operated, geared motors for this robot.
Here, we are using a 7.4 li-ion battery to power the whole circuit. You can use
any battery type from 6-12 volt. To move the robot, we need to use motors with
low RPM but torque high enough to carry the weight of the robot. So, I chose
two 60 RPM 6V Battery Operated, geared motors for this robot.
Here, we are using a 7.4 li-ion battery to power the whole circuit. You can use
any battery type from 6-12 volt. To move the robot, we need to use motors with
low RPM but torque high enough to carry the weight of the robot. So, I chose
two 60 RPM 6V Battery Operated, geared motors for this robot. Here, we are
using a 7.4 li-ion battery to power the whole circuit. You can use any battery type
from 6-12 volt. To move the robot, we need to use motors with low RPM but
torque high enough to carry the weight of the robot. So, I chose two 60 RPM 6V
Battery Operated, geared motors for this robot. To make this robot, first we need
a robot body; here I am using a homemade chassis. You can either use a
readymade chassis or build one yourself.
Now, place the BO motors to the chassis with the help of some hot glue as shown
in the image below.
Next step is to place the motor driver on chassis and connect the motor wires to
the output of the motor driver.
Now place the Arduino uno using glue and connect the sensor output pins to
digital pin 2 and 4 of the Arduino.
Connect the VCC pins to 5volt and the ground pins to ground.
Now, connect the enable pins of the motor driver to pin 5 and 8 of Arduino and
connect the motor driver input pins to pin number 6, 7, 9 and 10 of Arduino
respectively.
Finally, connect the battery with the circuit and place the battery on chassis.
Here, I have connected everything with jumper wires. To make a permanent
setup, you can directly solder everything together.
To make this robot, first we need a robot body; here I am using a homemade
chassis. You can either use a readymade chassis or build one yourself.
Now, place the BO motors to the chassis with the help of some hot glue as shown
in the image below.
Next step is to place the motor driver on chassis and connect the motor wires to
the output of the motor driver.
Then place the sensors on the downside of the robot, adjust the sensors according
to the track width and robot width. Remember that one sensor is for left side
detection and another is for the right side detection.
Now place the Arduino uno using glue and connect the sensor output pins to
digital pin 2 and 4 of the Arduino.
Connect the VCC pins to 5volt and the ground pins to ground.
Now, connect the enable pins of the motor driver to pin 5 and 8 of Arduino and
connect the motor driver input pins to pin number `6, 7, 9 and 10 of Arduino
respectively.
Finally, connect the battery with the circuit and place the battery on chassis.
Here, I have connected everything with jumper wires. To make a permanent
setup, you can directly solder everything together.
First step is to defined every Arduino pin that we are using. I started with
motoring the driver pins and sensor pins. Here, I have commented on each line of
code for your easy understanding.
In the loop section, declare the pin modes of each pin. Here, we need to read the
output of IR sensors, hence I have defined those pins as an input. The motor
needs to be driven by the Arduino, thus defining the motor driver pins as output.
Finally, I pulled enable pin to high.
pinMode(R_S, INPUT);
pinMode(L_S, INPUT);
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enB, OUTPUT);
digitalWrite(enA, HIGH);
digitalWrite(enB, HIGH);
In the loop section, we first read the values of IR sensors and then using ‘if
condition’ control the movement of motor as per our requirements. The four
movement conditions are explained below.
Moving forward:
In this case, if Right Sensor and Left Sensor are on top of white colour then the
robot should move in the forward direction, so we call the forward function.
(Note : here 0 means output of IR sensor is high as the sensor is on white surface)
if Right Sensor is detecting Black and Left Sensor is not detecting any black line,
then it will call the Right function, initiating the protocol for making right turn by
calling turnRight function.
if Right Sensor is over white and the Left Sensor is detecting Black then it will
call turnLeft function. It will initiate the steps for turning the robot in left
direction.
If the Right Sensor and Left Sensor are on the Black color then it will call the
Stop function. In this case, the robot will come to a complete halt.
We have defined the 4 functions of the robot as Forward, turnLeft, turnRight and
Stop. The code to perform these functions are given below:
Forward function:
void forward(){
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
This means we are pulling to high the input 1 and 4 of the motor driver, as a
result, both motors will move forward same as this I made other functions
Turnright function:
void turnRight(){
digitalWrite(in1, LOW); //Right Motor forword Pin
digitalWrite(in2, HIGH); //Right Motor backword Pin
digitalWrite(in3, LOW); //Left Motor backword Pin
digitalWrite(in4, HIGH); //Left Motor forword Pin
}
TurnLeft function:
void turnLeft(){
digitalWrite(in1, HIGH); //Right Motor forword Pin
digitalWrite(in2, LOW); //Right Motor backword Pin
digitalWrite(in3, HIGH); //Left Motor backword Pin
digitalWrite(in4, LOW); //Left Motor forword Pin
}
Stop function:
void Stop(){
digitalWrite(in1, LOW); //Right Motor forword Pin
digitalWrite(in2, LOW); //Right Motor backword Pin
digitalWrite(in3, LOW); //Left Motor backword Pin
digitalWrite(in4, LOW); //Left Motor forward Pin
So, that’s all about coding. Now we need to upload the code to the Arduino and
to do so, connect your Arduino with the computer using USB cable and upload
this code using the Arduino IDE.
Now, since we have calibrated the robot, all we need to do is place the robot on
top of the black line and see it in action.
The complete making of the line follower robot can be found in the video linked
at the bottom of this page. If you have any questions leave them in the comment
section.
Code
Software Required:
o BASCOM-AVR Integrated Development Environment (IDE)
o AVRDUDE-GUI
o WinAVR-2010
o USBasp Driver
Block Diagram:
Algorithm:
1. R=rightmost sensor which reads 0, L=leftmost sensor which reads 0.
If no sensor on right (or Left) is 0 than L (or R) equals to 0.
2. If all sensor read 1 then go to step 3,
Else,