Back to: Robotics & Artificial Intelligence (Class IX)
A Line Follower Robot is an autonomous robot that follows a pre-defined path, usually a black line on a white surface or a white line on a black surface. It uses IR sensors to detect the line and a motor driver with Arduino to control movement.
How It Works
- IR Sensors detect the line:
- Black surface absorbs IR light → Sensor reads LOW (0)
- White surface reflects IR light → Sensor reads HIGH (1)
- Arduino processes the sensor data and decides the movement.
- Motor Driver controls the wheels based on Arduino’s instructions.
Components Required
- Arduino Uno – The brain of the robot
- Two IR Sensors – To detect the line
- L298N Motor Driver – To control motors
- Two DC Motors – For movement
- Robot Chassis – Body of the robot
- Power Source – 9V battery or Li-ion battery pack
- Jumper Wires – For connections
Connections

Programming
int LS=7;
int RS=8;
int LM1=9; // left motor
int LM2=10; // left motor
int RM1=11; // left motor
int RM2=12; // left motor
void setup()
{
Serial.begin(9600);
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}
void loop()
{
Serial.println(digitalRead(LS));
Serial.println(digitalRead(RS));
if((digitalRead(LS)==0) && (digitalRead(RS)==0)) //s
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
if((digitalRead(LS)==0) && (digitalRead(RS)==1)) //r
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, HIGH);
}
if((digitalRead(LS)==1) && (digitalRead(RS)==0)) //l
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if((digitalRead(LS)==1) && (digitalRead(RS)==1)) //f
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
}
Working Mechanism
🔹 Both sensors on the line → Move forward
🔹 Left sensor off the line → Turn right
🔹 Right sensor off the line → Turn left
🔹 Both sensors off the line → Stop
Applications of Line Follower Robot
✅ Automated Transportation – Used in warehouses for material handling
✅ Self-Driving Cars – Basic concept of lane following
✅ Industry Automation – Follows fixed paths for production lines
✅ Medical Assistance – Used in hospitals to deliver medicines