Embedded system applications (Arduino )
Embedded system applications (Arduino )
Applications (EC-506)
• IR (infrared) Transmitters (IR LED) and IR (infrared) receivers (TSOP 1738) also called as
photodiodes are used. They are used for sending and receiving light. IR transmits infrared lights (
wavelen
• When infrared rays falls on the white surface, it’s reflected back and caught by photodiodes which
generate some voltage changes. When IR light falls on a black surface, light is absorbed by the black
surface and no rays are reflected back, thus photo diode does not receive any light or rays.
• In this Arduino line follower robot when the sensor senses white surface then Arduino gets 1 as input
and when senses black line , Arduino gets 0 as input.
Functional Blocks of Line Follower Robot
Arduino line follower robot can be divided into 3 sections:
1) Sensor section:
IR Module which is a sensor circuit consists of IR diodes, potentiometer,
Comparator (Op-Amp) and LED’s. The 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 the comparator’s second terminal.
Then the comparator compares both voltages and generates a digital signal at the
output. Here in this line follower circuit, two comparators for two sensors are
used.
LM 358 is used as a comparator. LM358 has inbuilt two low noise Op-amps.
2) Control section:
Arduino UNO is used for controlling the whole process of the line follower
robot. The outputs of comparators are connected to digital pin numbers 2 and 3
of Arduino. Arduino read these signals and send commands to driver circuit to
drive line follower.
3) Driver section:
The driver section consists of motor driver IC ( L293D) and two DC motors.
The motor driver is used for driving motors because Arduino does not supply
enough voltage and current to the motor. So adding a motor driver circuit to
get enough voltage and current for the motor. Arduino sends commands to this
motor driver and then it drives motors.
Working of Line Follower Robot
• The line follower robot senses a black line by using a sensor and then sends
the signal to Arduino. Then Arduino drives the motor according to
sensors' output.
• Two IR sensor modules namely the left sensor and the right sensor are
used.
When both left and right sensor senses white then the robot moves forward.
If the left sensor comes on a black line then the robot turn the left side
If the right sensor sense black line then robot turn right side until both sensors
comes at the white surface. When the white surface comes robot starts moving
on forward again.
If both sensors come on the black line, the robot stops.
Circuit Diagram
• The 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 the output pin of motor drivers 3 and
6 and another motor is connected at pin 11 and 14.
Program
• /*------ Arduino Line Follower Code----- */
/*-------defining Inputs------*/
#define LS 2 // left sensor
#define RS 3 // right sensor
• /*-------defining 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);
}