I have improved the program (Program2)
I tried to incorporate the P control (proportional control) was also introduced at "Introduction to Line Trace".
I tried to figure the principle of work.
The position of the light sensor would be in the condition of " white 50: black 50 " set to return a value of 0. For that value, multiplied by the proportional gain (P Gain variables), transmit to the power of the motor. Green arrow is its power. If the positive power of the transmitted to the motor on the left, so that the negative power setting is transmitted to the motor on the right side.
Match the light sensor to the position of the "50 white: black 50", I will run the program.
No phenomenon is occurred such as running in a straight line to zigzag. However, it would continue around the curve, the robot went steadily shifted from the line, and fell from the table in the end.
Increasing the proportional gain (P Gain value of the variable) once, it can solve this bug, but the robot side effects that would dizzy by running in a straight line.
For information on how to resolve this issue, we will introduce the next page.