Line Following

There are many line following techniques. Some read the sensors and give them a weight and calculates outputs for motors with a PID. And some use different methods. Clearly, as I am a newbie I would like to know about the techniques you use. And an example code. And an explanation about how it works. :) :) Let's exchange line following methods here. Thanks in advance