PID control runs an enormous share of the physical world: thermostats, cruise control, drones, 3D printers, and the steering of self-driving cars. It sounds technical, but a line-following robot makes every part of it intuitive. The robot's job is simple: stay on the line. PID is how it decides how hard to turn.
The setup
A line follower has a sensor that tells it how far off the line it is. Call that the error: zero means dead center, positive means it has drifted right, negative means left. PID turns that error into a steering command, using three terms.
P, the proportional term
The simplest idea: steer in proportion to how far off you are. Drifted far right, turn hard left; barely off, turn gently.










