Yes, that's the idea. Strictly speaking, one light sensor does not allow you to "
follow the line", it allows you to "
follow the edge of a line". However, the algorithm outlined in that tutorial does not
follow the edge very smoothly. It is doing the zigzagging pattern. If you use
PID control, you will get much smoother edge following (i.e. instead of setting the wheels to 80% power one way or the other, the wheel power differential should be proportional to the difference of the light sensor reading and the THRESHOLD). You need to determine the threshold precisely by sampling the "white" value and the "dark" value and calculating the threshold by THRESHOLD = (whiteValue + darkValue)/2. Then use the threshold in your code, something like this:
Tune the KP value and the BASESPEED value until it follows the line smoothly. Also, depending on whether it is a white line on black floor or black line on white floor or if motorC is the left wheel or motorC is the right wheel, the above algorithm will either
follow the left edge or the right edge of the line.
Tips on tuning the parameters:
Do the initial tuning on a straight line. Start with a reasonably small BASESPEED (e.g. 30). Increase KP until the robot starts zigzagging, then decrease KP just enough to make it smooth again. If you want the robot to
follow the line faster, increase the BASESPEED, but you need to tune KP again for the new BASESPEED. If the line has a curve and robot always loses the line when following the curve, then you need to decrease BASESPEED (and of course tune KP again).