Introduction
A Line Following Robot is an autonomous robot that follows a predefined path, usually a black or white line, using sensors. The robot detects the line and moves accordingly without human intervention.
This project is widely used in robotics learning, industrial automation, and research applications.
Objective of the Project
- To design an autonomous robot that follows a line.
- To understand sensor-based navigation.
- To interface IR sensors with Arduino.
- To control DC motors using a motor driver.
Working Principle
The robot works on the principle of line detection using infrared (IR) sensors.
How It Works
- IR sensors detect reflected light from the surface.
- Black line absorbs light, white surface reflects it.
- Sensor output changes based on surface color.
- Arduino processes sensor data.
- Motor driver controls wheel movement to stay on track.
Components Required
- Arduino Uno
- IR Sensors (2 or 3)
- Motor Driver (L298N / L293D)
- DC Motors with Wheels
- Robot Chassis
- Battery
- Jumper Wires
Circuit Diagram
IR Sensor Connections
Left Sensor -> A0
Right Sensor -> A1
VCC -> 5V
GND -> GND
Motor Driver (L298N)
IN1 -> D8
IN2 -> D9
IN3 -> D10
IN4 -> D11
ENA -> D5
ENB -> D6
Arduino Code for Line Following Robot
int leftSensor = A0;
int rightSensor = A1;
int motor1A = 8;
int motor1B = 9;
int motor2A = 10;
int motor2B = 11;
void setup() {
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
pinMode(motor1A, OUTPUT);
pinMode(motor1B, OUTPUT);
pinMode(motor2A, OUTPUT);
pinMode(motor2B, OUTPUT);
}
void loop() {
int leftValue = digitalRead(leftSensor);
int rightValue = digitalRead(rightSensor);
if (leftValue == LOW && rightValue == LOW) {
forward();
}
else if (leftValue == LOW && rightValue == HIGH) {
turnRight();
}
else if (leftValue == HIGH && rightValue == LOW) {
turnLeft();
}
else {
stopRobot();
}
}
void forward() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
}
void turnLeft() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
}
void turnRight() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
}
void stopRobot() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, LOW);
}
Code Explanation
- IR sensors detect the line.
- Arduino makes decisions based on sensor input.
- Motor driver controls direction and speed.
- Robot follows the path automatically.
Advantages
- Fully autonomous
- Low cost
- High accuracy
- Educational project
Applications
- Industrial automation
- Warehouse robots
- Educational robotics
- Path-guided vehicles
Future Enhancements
- PID control for smoother movement
- Obstacle detection
- Wireless monitoring
- Speed control using PWM
Conclusion
The Line Following Robot is a classic robotics project that teaches sensor integration, motor control, and autonomous navigation. It is an essential project for students entering robotics and automation fields.
