Design and Implementation of Line Follower Robot Using Arduino Microcontroller
Design and Implementation of Line Follower Robot Using Arduino Microcontroller
International Journal of Scientific & Engineering Research, Volume 11, Issue 4, April-2020
ISSN 2229-5518
Index Terms— Arduino Uno R3, DC motor driver circuit, IR Array, Liquid crystal display, Transistor-transistor logic, Ultrasonic sensor, Voltage regulator
circuit.
—————————— ——————————
1 INTRODUCTION code to the Arduino is done by USB cable which connects Ar-
Recently, many line following robots have been designed and duino and the computer.
utilized. Line follower robot is a self operating mobile machine 2.2 Digital IR Array Sensor and Ultrasonic Sensor
that follows a line drawn on the floor. The path can be a visi- The line follower robot uses 7 array digital IR sensor array to
ble black line on white surface or vice versa. Using ultrasonic sense the line.Among them, five IR sensors are used with a
sensors and IR array sensors which are set up inside the robot, suitable distance from each other because there are six analog
the path location can be easily detected and followed. pins on Arduino. The IR sensors contain an infrared transmit-
IJSER
Line follower robot can be used in many industrial purposes. ter and infrared receiver pair. For balancing left and right side
It can be used in carrying heavy and risky products. It can also four sensors are used and one middle sensor for line detection.
transport radioactive material in a nuclear power plant. In On each IR sensor, there are two diodes. One of them send
restaurant, this robot can take orders and serve food accord- Infrared rays and another one receives it. If the receiver re-
ingly. ceives more reflected light than it is on the white surface and if
In this paper, the detailed component wise construction will receives less reflected light (or doesn't receive any reflected
be discussed in section 2, circuit diagram and working princi- light) that means it is on the black surface.One IR sensor in-
ple will be explained in section 3, flow chart and relevant ex- cludes one infrared transmitter and one receiver. IR sensor
planations 4 will be discussed in section and the program- array is the combination of five IR reflectance-sensors. The
ming part 5will be illustrated in section. distance between the surface and the IR sensors array should
be less than 5mm and distance between two IR sensors de-
2 COMPONENTS OF LINE FOLLOWER ROBOT pends on line width. If the line width is narrow, the distance
2.1 Arduino UNO R3 and IDE between the sensors must be reduced; otherwise, while curv-
Arduino Uno R3 is a microcontroller board based on the AT- ing the line, the robot will not be turned on time. The sensors
mega328P (datasheet). It has 6 analog input pins and 13 digital work well if it is shielded from ambient light. The ultrasonic
all of which can be used as PWM outputs, 16 MHz quartz sensor detects obstacles from a predefined distance and sends
crystal, a USB connection, power jack and a reset button. It a signal to Arduino UNO R3 sensor through trigger pin to
contains everything needed to support the microcontroller; by respond accordingly. The sensor operates on 5V DC. This sen-
simply connecting it to a computer with a USB cable one can sor protects the robot from collisions due to obstacles.
program it. It supports 5V DC to 12 V DC. The safe power
supply is 9V DC. Arduino controls the whole robot actions. 2.3 DC Motor Driver Circuit
The motor shield is placed above it. Motor shield's pins are A well-known and suitable motor driver is IC L298 which can
connected to Arduino's pins. be used to control two motors. It is a high voltage, high-
current dual full-bridge driver designed to accept standard
Arduino IDE is used for writing a program and inserting the TTL logic levels and drive inductive loads such as DC and
stepping motors [3]. Two enable inputs of 5 volts are provided
———————————————— to enable or disable the device independently of the input sig-
Quazi Taif Sadat is currently working as Director, Innnovation Lab in nals. L298 has 2 amperes per channel current capacity and it
Bangladesh University, Bangladesh, E-mail: [email protected] can support from 3 volts to 30 volts for outputting. Moreover,
Syed Khalid Rahman is currently working as Senior Lecturer in Bangla- L298 works well up to 16 volts without any heat sink.
desh University, Bangladesh, E-mail: [email protected]
Tabassum E Nur is currently working as Senior Lecturer in Bangladesh
University, Bangladesh, E-mail: [email protected] 2.4 Voltage Regulator Circuit
Neelanjana Subin Ferdous is currently working as Lecturer in Bangladesh The voltage regulator circuit contains a diode 1N4007, two
University, Bangladesh, E-mail: [email protected] capacitors of 100uF, one resistor of 10k and a BC547 model
transistor. It converts the incoming DC signal of 12 volts from
IJSER © 2020
http://www.ijser.org
1450
International Journal of Scientific & Engineering Research, Volume 11, Issue 4, April-2020
ISSN 2229-5518
5 volts for proper component wise operation. The circuit is values accordingly. Lastly, the reading achieved from ultra-
connected to other components to ensure accurate supply of sonic sensors indicates that whether there is an obstacle in
voltage. following the line or not.
2.5 Chassis Board
Robot body is another important thing. One can use many
kinds of chassis but it should be kept in mind that the chassis
has to support all devices and has to be strong.It can be made
from glass, plastic, Aluminium or any other lightweight mate-
rials.
The authors have made car shape line follower robot. Devices
are installed above the chassis and motorsand sensors are in-
stalled below the chassis by screws.
3 CIRCUIT DIAGRAM
IJSER
Fig. 1. Circuit diagram of the line follower robot.
SOURCE CODE
Arduino microcontroller has its own IDE for coding. It sup-
ports C as a programming language. Arduino IDE has it’s own
the signals received from IR array and ultrasonic array. As the facility to connect Arduino to computer via USB cable and
IR array consists of five sensors, the location of the line is spec- passes enough current and code through it.
ified from the intensity of responses from the five sensors. At #include<LiquidCrystal.h>
the same time, the voltage regulator circuit maintains a con- LiquidCrystal lcd(11, 10, 9, 8, 7, 6);
stant 9V input in the microcontroller.The current location, mo- const int buzzer = A5;
tion speed and other parameters are constantly and updated const int trigPin = 13;
in LCD display. Based on responses of IR and ultrasonic sen- const int echoPin = 12;
sors, the programmable microcontroller generates an output unsigned int avg_distance = 0;
which is driven to motor driver circuit. The motor driver cir- unsigned int avg_distance1 = 0;
cuit controls the direction of rotation of motor according to the long duration;
inputs received from the Arduino UNO R3 microcontroller. int distance;
double alpha = 0.75;
int period = 100;
4 FLOW CHART
double change = 0.0;
After initializing the LCD and ultrasonic sensors, the micro-
double minval = 0.0;
controller will read the IR array to locate the position of the
int d = 0;
path. Of the five IR array sensors, if the response is achieved
int reaDy = 0;
from sensor from position greater or less than 3, then it is
int LL, LM, M, RM, RR;
checked that whether the input is received from sensor posi-
int right_duty = 100, left_duty = 100;
tion 2 or 4. Depending on the number of position from which
void beep()
the input signal is received from microcontroller, the PWM of
{
the motor driver circuit is increased or decreased to specific
digitalWrite(buzzer, HIGH); delay(100);
IJSER © 2020
http://www.ijser.org
1451
International Journal of Scientific & Engineering Research, Volume 11, Issue 4, April-2020
ISSN 2229-5518
IJSER
void loop() go_forward();
{ right_duty = 255;
read_line(); left_duty = 0;
Distance_measurement(); }
if (reaDy == 1 && avg_distance1 < 20) // obstracle ahead else if (LL == LOW && LM == LOW && M == LOW && RM
{ == LOW && RR == LOW) //in line + end point
beep(); {
StoP(); StoP();
lcd.setCursor(0, 1); beep();beep();
lcd.print("Obstracle! "); go_back();
delay(1000); delay(1000);
reaDy = 0; StoP();
} delay(1000);
else if (reaDy == 1 && avg_distance1 > 20) right_duty = 0;
{ left_duty = 0;
lcd.setCursor(0, 1); }
lcd.print("Clear ahead "); }
delay(100); void read_line()
drive(); {
} LL = digitalRead(A0);
LM = digitalRead(A1);
M = digitalRead(A2);
}//end of void loop RM = digitalRead(A3);
RR = digitalRead(A4);
void drive() lcd.setCursor(11, 0);
{ lcd.print(LL);
if (LL == HIGH && LM == HIGH && M == LOW && RM == lcd.print(LM);
HIGH && RR == HIGH) //in line lcd.print(M);
{ lcd.print(RM);
go_forward(); lcd.print(RR);
right_duty = 255; }
left_duty = 255; void go_forward()
} {
else if (LL == HIGH && LM == HIGH && M == HIGH && analogWrite(2, right_duty);//right forward
RM == LOW && RR == HIGH) //in line+little right digitalWrite(3, LOW);
IJSER © 2020
http://www.ijser.org
1452
International Journal of Scientific & Engineering Research, Volume 11, Issue 4, April-2020
ISSN 2229-5518
d++;
analogWrite(4, left_duty); //left forward if (d > 2)
digitalWrite(5, LOW); {
} avg_distance /= 2;
avg_distance1 = avg_distance;
void go_back() avg_distance = 0;
{ // Prints the distance on the Serial Monitor
digitalWrite(2, LOW);//right backward d = 0;
digitalWrite(3, HIGH); reaDy = 1;
lcd.setCursor(0, 0);
digitalWrite(4, LOW); //left backward lcd.print("Dist:");
digitalWrite(5, HIGH); lcd.print(avg_distance1);
} lcd.print("cm ");
}
void turn_right() Serial.print("Distance: ");
{ Serial.println(avg_distance1);
digitalWrite(2, LOW);//right backward }
analogWrite(3, right_duty);
//
analogWrite(4, left_duty); //left forward 6 END SECTION
digitalWrite(5, LOW);
} 6.1 Conclusion
IJSER
The robot is capable of following any curve or cycle. Highly effi-
void turn_left() cient stepper motors can be used to control the speed of line fol-
{ lower robot. For better detection of obstacles along the line.
analogWrite(2, right_duty);//right forward
digitalWrite(3, LOW); ACKNOWLEDGMENT
The authors acknowledge financial and technical aid for this
digitalWrite(4, LOW); //left backward research received from Bangladesh University.
analogWrite(5, left_duty);
} REFERENCES
[1] N.M.A Ghani, F. Naim, T.P. Yon, “Two Wheels Balancing Robot with Line
void StoP() Following Capability,” World Academy of Science, Engineering and Technology,
{ pp-634-638, 2011.
[2] A. Pathak, R.K Pathan, A.U. Tutul, N.T Tousi, A.S. Rubaba, N.Y. Bithi, “Line
digitalWrite(2, LOW);//right stop Follower Robot for Industrial Manufacturing Process”, International Journal of
digitalWrite(3, LOW); Engineering Inventions, pp-10-17, October 2017.
[3] M. Engin1, D. Engin, “Path Planning of Line Follower Robot”, Pro-
digitalWrite(4, LOW); //left stop ceedings of the 5th European DSP Education and Research Conference, 2012.
digitalWrite(5, LOW); [4] M.M. Myint, N.K. Soe, “Line Follower Robot using Line Tracing
Sensors”, International Journal of Science, Engineering and Technology Re-search
} (IJSETR), pp-561-563, August, 2018
void Distance_measurement()
{
// Clears the trigPin//Sonar module HC-SR04
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in
microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;// extract distance into cm
value
avg_distance += distance;
IJSER © 2020
http://www.ijser.org