... and here's a demo of a line following robot using PID
What Is PID?
Let's say that you're building a line following robot like the one above. You've found a line following sensor, perhaps the LineDog, that you think will work well. It senses when the sensor is directly over the line, producing zero error, and when the sensor is to the right or left of the line, producing a positive or negative number indicating which side of the line the sensor is on (the sign of the error) and how far from the line the sensor is (the magnitude of the error). Now what?
A very common solution to this control problem is to use what is know as PID, which is an acronym that stands for Proportional, Integral, and Derivative. Typically, the control systems like this are analyzed using Laplace transforms and other higher mathematical tools. However, we've prepared a set of slides that explain PID at a more intuitive level. Hope you find this a good introduction.