Line Following Robot with Obstacle Avoidance
The Line Following Robot with Obstacle Avoidance is an Arduino-based project that combines precise line-tracking capabilities with intelligent obstacle detection.
The robot employs an H-bridge motor driver to control its movements, with infrared (IR) sensors for accurate line following. These IR sensors, positioned on both the left and right sides, enable the robot to discern and stay on a predefined path.
To enhance its functionality, the project integrates an ultrasonic distance sensor for obstacle detection. When an obstacle is detected within a certain range, the robot responds by activating a red LED indicator and halting its motors, showcasing an efficient obstacle avoidance mechanism.
The robot’s speed is dynamically adjusted based on readings from photodiode sensors, contributing to smooth and responsive line following.
A green LED serves as a visual indicator of successful line tracking. The combination of these features creates a versatile robot capable of autonomously navigating a path while intelligently avoiding obstacles in its way.
Component List:
Name | Quantity | Component |
---|---|---|
U1 | 1 | Arduino Uno R3 |
U2 U3 | 2 | Photodiode |
M2 M3 | 2 | DC Motor |
U4 | 1 | H-bridge Motor Driver |
R4 R5 | 2 | 10 kΩ Resistor |
R7 R8 | 2 | 1 kΩ Resistor |
DIST1 | 1 | Ultrasonic Distance Sensor |
D1 | 1 | Red LED |
D2 | 1 | Green LED |
U5 U6 | 2 | IR sensor |
The circuit incorporates an Arduino board, an H-bridge motor driver, infrared sensors, an ultrasonic distance sensor, LEDs, and photodiode sensors. The H-bridge controls motor movements, IR sensors enable line tracking, and the ultrasonic sensor detects obstacles. LEDs provide visual feedback, and photodiode sensors regulate motor speed. The circuit’s modular design promotes flexibility and scalability, allowing for further enhancements and customisation.
Arduino code:
int MA = 4;
int MB = 5;
int MC = 6;
int MD = 7;
long time;
int dis;
const int LEFT_SENSOR_PIN = A1;
const int RIGHT_SENSOR_PIN = A0;
const float detection_value = 0.5;
void setup() {
pinMode(MA, OUTPUT);
pinMode(MB, OUTPUT);
pinMode(MC, OUTPUT);
pinMode(MD, OUTPUT);
pinMode(13, INPUT);
pinMode(12, INPUT);
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, INPUT);
pinMode(9, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
ULTSONIC();
}
void ULTSONIC() {
digitalWrite(9, LOW);
delayMicroseconds(2);
digitalWrite(9, HIGH);
delayMicroseconds(10);
digitalWrite(9, LOW);
time = pulseIn(2, HIGH);
dis = time * 0.034 / 2;
if (dis <= 50) {
digitalWrite(11, HIGH);
digitalWrite(3, LOW);
float LEF_VALUE = analogRead(LEFT_SENSOR_PIN);
LEF_VALUE = (LEF_VALUE / 1024) * 0;
float RIG_VALUE = analogRead(RIGHT_SENSOR_PIN);
RIG_VALUE = (RIG_VALUE / 1024) * 0;
} else {
digitalWrite(11, LOW);
digitalWrite(3, HIGH);
float LEF_VALUE = analogRead(LEFT_SENSOR_PIN);
LEF_VALUE = (LEF_VALUE / 1024) * 5;
float RIG_VALUE = analogRead(RIGHT_SENSOR_PIN);
RIG_VALUE = (RIG_VALUE / 1024) * 5;
if (LEF_VALUE > detection_value) {
digitalWrite(MA, 1);
digitalWrite(MB, 0);
} else {
digitalWrite(MA, 0);
digitalWrite(MB, 0);
}
if (RIG_VALUE > detection_value) {
digitalWrite(MC, 1);
digitalWrite(MD, 0);
} else {
digitalWrite(MC, 0);
digitalWrite(MD, 0);
}
}
}
This Line Following Robot with Obstacle Avoidance project demonstrates the synergy of precise line tracking and obstacle avoidance, showcasing the potential for applications in automated logistics, robotics competitions, and educational settings.
Its adaptability and responsiveness make it a valuable addition to the realm of autonomous robotic systems.