Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

Line Follower Robot using Arduino | Code, Circuit, Components, Working

This page on Line Follower Robot using Arduino describes line follower robot circuit working operation, components and line follower robot code.

Introduction:
Following project has been developed using arduino UNO board and other components as listed below. It uses infrared sensors, motors, wheels and motor driver card.

Line Follower Robot Components

Following are the list of line follower Robot Components.
• Arduino Uno Board
• IR sensors (Two)
• DC motors (Two)
• Single 9V battery or Series of 1.5V (6 Nos)
• ON/OFF Switch
• Motor Driver card (L298N)

Line Follower Robot Circuit

Following is the complete circuit diagram of the line follower robot. Switch can be connected in series with the battery before it provides power to the board and other components of the line follower robot.

Line Follower Robot Using Arduino

As shown in the figure-1, the robot consists of arduino board. This robot stops when IR sensors find black line below it and runs when IR sensors find white or other than black color on their way.

Line Follower Robot Working

Function of IR sensors in line follower robot

IR sensors are used to detect the obstacles. This robot uses IR sensors. This line follower robot is designed to follow the black line by detecting white background and stops when it finds black background. The same is demonstrated in the video below.

IR sensors provide output as zero or one based on presence of obstacle. In this case it provides output based on black or non black (i.e. white) color. When there is black color, output is one and as per arduino code it stops the motor driver output and consecutively motors are OFF. When there is white color in front of IR sensors, output is zero and as per code it generates motor driver output and consecutively motors are ON and robot moves forward due to movement of wheels.

Infrared sensor

Refer IR sensors basics >> for working operation of infrared sensors.

Line Follower Robot Code

Following is the arduino code compiled and uploaded to the arduino board using Arduino IDE.

/*------ 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 (digitalRead(LS) && digitalRead(RS))
{
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 !(digitalRead(LS)) && !(digitalRead(RS))
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
}

Line Follower Robot Video

One can cut black chart paper as shown in the video and paste the same on the white chart for demonstration.

Conclusion: In this application note we have seen line follower robot using arduino and IR sensors. Arduino board is also used for interfacing different types of sensors for applications. The typical sensors interfaced with arduino are heartrate sensor, sound sensor, gyro sensor, LDR sensor, GPS sensor, color sensor, pH sensor etc.

IoT system on chip tutorial Related Links

This tutorial section on IoT (Internet of Things) covers following sub topics:
Main tutorial  IoT section  IoT article  Cellular IoT  Components  Sensors  INDIAN companies  Antenna Types  Wireless technologies  IoT transceiver  SoC 


RF and Wireless Terminologies


Share this page

Translate this page