Line follower Robot is a machine which follows a line, either a black line or white line. Basically there are two types of line follower robots: one is black line follower which follows black line and second is white line follower which follows white line. Line follower actually senses the line and run over it.
Concepts of Line Follower
Concept of working of line follower is related to light. We use here the behavior of light at black and white surface. When light fall on a white surface it is almost full reflected and in case of black surface light is completely absorbed. This behavior of light is used in building a line follower robot.
In this arduino based line follower robot we have used IR Transmitters and IR receivers also called photo diodes. They are used for sending and receiving light. IR transmits infrared lights. When infrared rays falls on white surface, it’s reflected back and catched by photodiodes which generates some voltage changes. When IR light falls on a black surface, light is absorb by the black surface and no rays are reflected back, thus photo diode does not receive any light or rays.
Here in this arduino line follower robot when sensor senses white surface then arduino gets 1 as input and when senses black line arduino gets 0 as input.
Circuit Explanation
The whole arduino line follower robot can be divided into 3 sections: sensor section, control section and driver section.
Sensor section:
This section contains IR diodes, potentiometer, Comparator (Op-Amp) and LED’s. Potentiometer is used for setting reference voltage at comparator’s one terminal and IR sensors are used to sense the line and provide a change in voltage at comparator’s second terminal. Then comparator compares both voltages and generates a digital signal at output. Here in this line follower circuit we have used two comparator for two sensors. LM 358 is used as comparator. LM358 has inbuilt two low noise Op-amps.
Control Section:
Arduino Pro Mini is used for controlling whole the process of line follower robot. The outputs of comparators are connected to digital pin number 2 and 3 of arduino. Arduino read these signals and send commands to driver circuit to drive line follower.
Driver section:
Driver section consists motor driver and two DC motors. Motor driver is used for driving motors because arduino does not supply enough voltage and current to motor. So we add a motor driver circuit to get enough voltage and current for motor. Arduino sends commands to this motor driver and then it drive motors.
Working of Line Follower Robot using Arduino
Working of line follower is very interesting. Line follower robot senses black line by using sensor and then sends the signal to arduino. Then arduino drives the motor according to sensors' output.
Here in this project we are using two IR sensor modules namely left sensor and right sensor. When both left and right sensor senses white then robot move forward.
If left sensor comes on black line then robot turn left side.
If right sensor sense black line then robot turn right side until both sensor comes at white surface. When white surface comes robot starts moving on forward again.
If both sensors comes on black line, robot stops.
Circuit Diagram
Complete circuit diagram for arduino line follower robot is shown in the above iamge. As you can see output of comparators is directly connected to arduino digital pin number 2 and 3. And motor driver’s input pin 2, 7, 10 and 15 is connected to arduino's digital pin number 4, 5, 6 and 7 respectively. And one motor is connected at output pin of motor driver 3 and 6 and another motor is connected at pin 11 and 14.
Program Explanation
In program, first of all we defined input and output pin, and then in loop we checks inputs and sends output according to inputs to output pin for driving motor. For checking input pin we used “if” statements.
There are four conditions in this line following robot that we read by using arduino. We have used two sensor namely left sensor and right sensor.
Input
|
Output
|
Movement
Of Robot
| ||||
Left Sensor
|
Right Sensor
|
Left Motor
|
Right Motor
| |||
LS
|
RS
|
LM1
|
LM2
|
RM1
|
RM2
| |
0
|
0
|
0
|
0
|
0
|
0
|
Stop
|
0
|
1
|
1
|
0
|
0
|
0
|
Turn Right
|
1
|
0
|
0
|
0
|
1
|
0
|
Turn Left
|
1
|
1
|
1
|
0
|
1
|
0
|
Forward
|
We write the arduino line follower code according to the conditions shown in table above.
Required Components
Arduino
In our Project we have used a microcontroller to control whole the process of system that is ARDUINO. Arduino is an open source hardware and very useful for project developments. There are many types of arduino like Arduino UNO, arduino mega, arduino pro mini, Lilypad etc. available in the market. Here we have used arduino pro mini in this project as arduino pro mini is small and so breadboard compatible. To burn program we have used FTDI burner.
L293D Motor Driver
L293D is a motor driver IC which has two channels for driving two motors. L293D has two inbuilt Transistor Darlington pair for current amplification and a separate power supply pin for giving external supply to motors.
IR Module:
IR Module is sensor circuit which consists IR LED/photodiode pair, potentiometer, LM358, resistors and LED. IR sensor transmits Infrared light and photo diode receives the infrared light.
Power Supply
I have added a voltage regulator to get 5 volt for arduino, comparator and motor driver. And a 9 volt battery is used to power the circuit.
Code
/*------ Arduino Line Follower Code----- */
/*-------definning Inputs------*/
#define LS 2 // left sensor
#define RS 3 // right sensor
/*-------definning Outputs------*/
#define LM1 4 // left motor
#define LM2 5 // left motor
#define RM1 6 // right motor
#define RM2 7 // right motor
void setup()
{
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}
void loop()
{
if(digitalRead(LS) && digitalRead(RS)) // Move Forward
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if(!(digitalRead(LS)) && digitalRead(RS)) // Turn right
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if(digitalRead(LS) && !(digitalRead(RS))) // turn left
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
if(!(digitalRead(LS)) && !(digitalRead(RS))) // stop
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
}
More Programming:-
int Left_n=3;
int Right_p=4;
int Right_n=5;
void setup()
{
pinMode(Left_p,OUTPUT);
pinMode(Left_n,OUTPUT);
pinMode(Right_p,OUTPUT);
pinMode(Right_n,OUTPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
}
void loop()
{
int ex_right=analogRead(A0);
int right=analogRead(A1);
int centre=analogRead(A2);
int left=analogRead(A3);
int ex_left=analogRead(A4);
if(ex_left<700 amp="" ex_right="" span="">700>
{
digitalWrite(Left_p,HIGH);
digitalWrite(Left_n,LOW);
digitalWrite(Right_p,HIGH);
digitalWrite(Right_n,LOW);
}
if(ex_left>700 && ex_right<700 span="">700>
{
digitalWrite(Left_p,HIGH);
digitalWrite(Left_n,LOW);
digitalWrite(Right_p,LOW);
digitalWrite(Right_n,LOW);
}
if(ex_left<700 amp="" ex_right="">700)700>
{
digitalWrite(Left_p,LOW);
digitalWrite(Left_n,LOW);
digitalWrite(Right_p,HIGH);
digitalWrite(Right_n,LOW);
}
}
Motor Driver IC.
I liked the way you wrote it. You did not divert from the topic even once which I have not seen in many other writers. Also the subject knowledge is appreciable. Facet Optical Polishing by Valley Design.
ReplyDeleteNicely written post! I must thank you for posting this blog because the topic is very much in demand today and everyone wants to read about it. Thanks. Aluminum Nitride CNC Machining Services.
ReplyDeleteI’ve been reading numerous articles on this topic but found this one uniquely written. Thanks. Lapped Ceramic Substrates From Valley Design.
ReplyDelete