This project is an autonomous line follower robot that uses an Arduino Nano and an array of IR sensors to navigate a black line on a white surface. The core of this project is the implementation of a PID (Proportional-Integral-Derivative) control algorithm, which allows the robot to follow the line smoothly and at high speed by continuously correcting its path.
- High-Speed Line Following: Designed to follow a track accurately, even at higher speeds.
- PID Control Algorithm: Implements a closed-loop PID controller to minimize error, reduce oscillation, and achieve smooth, stable movement around curves and straight paths.
- IR Sensor Array: Utilizes an array of three IR (Infrared) sensors to precisely detect the line's position relative to the robot.
- Autonomous Navigation: The robot operates autonomously, making real-time decisions to adjust motor speeds based on sensor feedback.
- Modular Hardware: Built with common and accessible components like the Arduino Nano and an L298N motor driver.
| Component | Quantity | Purpose |
|---|---|---|
| Arduino Nano | 1 | The main microcontroller (brain) running the PID algorithm. |
| L298N Motor Driver | 1 | Controls the speed and direction of the two DC motors. |
| IR Sensor Module | 3 | Detects the black line on the surface. |
| 100 RPM DC Motors | 2 | Drives the wheels of the robot. |
- Robot Chassis & Wheels | 1 set | The mechanical frame of the robot. | Battery | 1 | Powers the Arduino, sensors, and motors. |
The circuit connects the IR sensors to the Arduino's analog pins, and the Arduino's digital pins control the L298N Motor Driver to power the motors.
The robot's operation is based on a continuous feedback loop managed by the PID controller.
-
Sensing the Line: The array of three IR sensors constantly measures the reflectance of the surface below. A black line reflects less light than a white surface, generating different analog voltage levels from the sensors.
-
Calculating the Error: The Arduino Nano reads the analog values from the three sensors and calculates a weighted sum to determine an "error" value.
- If the robot is perfectly centered, the error is zero.
- If the robot drifts to the right, a positive error is generated.
- If the robot drifts to the left, a negative error is generated.
-
PID Control Logic: The calculated error is fed into the PID algorithm:
- Proportional (P): Reacts to the current error. A larger error results in a sharper turn.
- Integral (I): Accumulates past errors to correct any consistent, steady-state drift or bias (e.g., one motor being slightly faster).
- Derivative (D): Anticipates future errors by observing the rate of change of the error. This helps to dampen oscillations and prevent the robot from overshooting the line on sharp turns.
-
Motor Control: The final output of the PID controller is a correction value. This value is used to adjust the speed of the left and right motors via the L298N driver, steering the robot back towards the center of the line.
During development, several challenges were addressed to improve performance:
- Issue: The robot was unable to handle sharp turns effectively.
- Solution: Adding more IR sensors to the array would provide a wider field of view and allow for more sophisticated turn logic.
- Issue: One of the motors did not provide enough torque at low RPMs, causing inconsistent movement.
- Solution: Swapping the motors for a higher quality, more sensitive model would ensure both motors respond consistently to the PWM signals from the PID controller.
- Issue: The PID controller would overshoot when the base speed was set too high.
- Solution: Fine-tuning the Kp, Ki, and Kd constants is critical. A more sensitive motor would also help the system react more predictably to PID outputs.
