How to make Arduino Line Follower Robot
A
line follower robot, as the name suggests, is an automated guided
vehicle, which follows a visual line embedded on the floor or ceiling.
Typically, the visual line is the path in which the line follower robot
goes and it will be a black line on a white surface but another path (a
white line on a black surface) is also possible. Some advanced line
follower robots use invisible magnetic fields as their paths.
Large line follower robots are commonly used in industries to aid the automated production process. They are also used in military applications, human support purposes, delivery services, etc.
The line follower robot is the first robot to get its first robotic experience with beginners and students. In this project, we have designed a simple line follower robot using Arduino and some other components.
Large line follower robots are commonly used in industries to aid the automated production process. They are also used in military applications, human support purposes, delivery services, etc.
The line follower robot is the first robot to get its first robotic experience with beginners and students. In this project, we have designed a simple line follower robot using Arduino and some other components.
![]() |
Line Follower Robot 1 |
![]() |
Line Follower Robot 2 |
![]() |
Line Follower Robot 3 |
![]() |
Line Follower Robot 4How to make Arduino LFR (Line Follower Robot) : Essential components |
1. Arduino UNO (or Arduino Nano) [Buy Here]
2.L293D Motor Driver IC [Buy Here]
3. Gear x 2
4. Robot Chassis
5. IR sensor module x 2
6. Black tape (electrical insulation tape)
7. Connecting the wires
8. Power Supply
9. Battery Connector
10.Battery
2.L293D Motor Driver IC [Buy Here]
3. Gear x 2
4. Robot Chassis
5. IR sensor module x 2
6. Black tape (electrical insulation tape)
7. Connecting the wires
8. Power Supply
9. Battery Connector
10.Battery
How to make Arduino Line Follower Robot : circuit diagram
![]() |
Arduino Line Follower Robot Circuit |
Project block diagram
The line follower robot manufactured in this project is divided into 4 blocks. The following image depicts the block diagram for the line follower robot.
![]() |
Block diagram description |
IR sensor module
As mentioned earlier, we have used the pre-assembled IR sensor. If you do not have one, you can make your own sensor using the following circuit.
![]() |
IR Sencer |
How to make Arduino Line Follower Robot : IR sensor circuit
![]() | ||
IR Sencer Circuit |
Controller (Arduino UNO): Arduino UNO is the main controller in the project. The data from the sensor (IR sensor) will be passed to the Arduino and it gives the corresponding signal to the motor driver IC.
Motor Driver (L293D): L293D Motor Driver IC is used in this project to drive robot motors. It receives signals from the Arduino based on the information from the IR sensor.
Note: The power supply to the motors must be supplied from the motor driver IC. Therefore, select the appropriate power supply that is sufficient for all components, including motors.
Motors (geared motor): We have used two geared motors behind the line follower robot. These motors provide more torque than normal motors and can also be used to lift some loads.
How to make Arduino Line Follower Robot: Working of Arduino Line Follower Robot
In
this project, we have designed an Arduino based line follower robot.
The project work is very simple: find the black line on the surface and
move along that line. Detailed work is explained here.
As mentioned in the block diagram, we need a sensor to detect the line. For line detection logic, we used two IR sensors, which include IR LED and Photodiode. They are placed in a reflective manner i.e. side-by-side so that whenever they come in proximity to a reflective surface, the light emitted by the IR LED can be detected by the photo diode.
The following image shows the work of a specific IR sensor (IR LED - photodiode pair) in front of a light colored surface and a black surface. Since the reflectance of the light colored surface is high, the infrared light emitted by the IR LED will be reflected maximum and detected by the photodiode.
How to make Arduino Line Follower Robot
As mentioned in the block diagram, we need a sensor to detect the line. For line detection logic, we used two IR sensors, which include IR LED and Photodiode. They are placed in a reflective manner i.e. side-by-side so that whenever they come in proximity to a reflective surface, the light emitted by the IR LED can be detected by the photo diode.
The following image shows the work of a specific IR sensor (IR LED - photodiode pair) in front of a light colored surface and a black surface. Since the reflectance of the light colored surface is high, the infrared light emitted by the IR LED will be reflected maximum and detected by the photodiode.
How to make Arduino Line Follower Robot

IR sensor working |
IR sensor working
In the case of black surface, which has low reflectance, light is completely absorbed by the black surface and does not reach the photodiode.
Using the same principle, we will setup the IR sensor on a line follower robot, such that two IR sensors are on either side of the black line on the floor. The setup is shown below.
The Arduino UNO detects this change and sends the signal to the motorist accordingly. To turn right, the motor on the right of the robot is slowed down using PWM, while the motor on the left is driven at normal speed.
IR follower line follower in left right
Similarly, when the IR sensor 2 first detects the black line, it means that there is a forward left curve and the robot has to turn left. To turn the robot left, the motor on the left side of the robot is slowed down (or can be stopped completely or rotated in the opposite direction) and the motor on the right is driven at normal speed.
The Arduino UNO continuously monitors data from both sensors and turns on the robot according to the line they searched.
How to make Arduino Line Follower Robot: CODE
int mot1=9; int mot2=6; int mot3=5; int mot4=3; int left=13; int right=12; int Left=0; int Right=0; void LEFT (void); void RIGHT (void); void STOP (void); void setup() { pinMode(mot1,OUTPUT); pinMode(mot2,OUTPUT); pinMode(mot3,OUTPUT); pinMode(mot4,OUTPUT); pinMode(left,INPUT); pinMode(right,INPUT); digitalWrite(left,HIGH); digitalWrite(right,HIGH); } void loop() { analogWrite(mot1,255); analogWrite(mot2,0); analogWrite(mot3,255); analogWrite(mot4,0); while(1) { Left=digitalRead(left); Right=digitalRead(right); if((Left==0 && Right==1)==1) LEFT(); else if((Right==0 && Left==1)==1) RIGHT(); } } void LEFT (void) { analogWrite(mot3,0); analogWrite(mot4,30); while(Left==0) { Left=digitalRead(left); Right=digitalRead(right); if(Right==0) { int lprev=Left; int rprev=Right; STOP(); while(((lprev==Left)&&(rprev==Right))==1) { Left=digitalRead(left); Right=digitalRead(right); } } analogWrite(mot1,255); analogWrite(mot2,0); } analogWrite(mot3,255); analogWrite(mot4,0); } void RIGHT (void) { analogWrite(mot1,0); analogWrite(mot2,30); while(Right==0) { Left=digitalRead(left); Right=digitalRead(right); if(Left==0) { int lprev=Left; int rprev=Right; STOP(); while(((lprev==Left)&&(rprev==Right))==1) { Left=digitalRead(left); Right=digitalRead(right); } } analogWrite(mot3,255); analogWrite(mot4,0); } analogWrite(mot1,255); analogWrite(mot2,0); } void STOP (void) { analogWrite(mot1,0); analogWrite(mot2,0); analogWrite(mot3,0); analogWrite(mot4,0); }
Note:
- To increase the efficiency of black line detection, the number of sensors can be increased. An array of sensors would be more accurate than just two sensors.
- In this project (where two sensors are used), the position of the sensor is very important. The width of the black line plays a major role in the placement of the sensor.
- Sensors can also be constructed for line detection using an LED and LDR pair.
Line follower robot applications
- Line follower robots are commonly used for automation processes in industries, military applications, and consumer applications.
- They are very useful as they can operate without any supervision i.e. they operate as automatic guided vehicles.
- Line follower robots can be used in driverless cars, with additional features such as obstacle avoidance and other safety measures.