A line-following robot detects a dark line on a light surface (or vice versa) and steers to stay on track.
Hardware
- Microcontroller (Arduino/Nano)
- IR array sensors (3–5)
- 2x DC gear motors, wheels, caster
- Motor driver, battery pack
Software
// Pseudocode
read_sensors();
error = target - measured_line_position;
output = Kp*error + Ki*sum(error) + Kd*d(error)/dt;
set_motor_speeds(base + output, base - output);
Tune PID gains gradually. Start with Kp, then add Kd to reduce overshoot, and finally Ki to remove steady-state error.