The major problems in this program was in getting the threshold values for the light sensors correct. The line sensor thresholds posed the greatest problems if they were not calculated properly. At first only one threshold value was used for the tracking. If the sensor value was greater the robot would go right, else it would go left. The problem with this is when both sensors are of equal value, as in the instance when it is crossing an intersection or on the line perfectly, the robot should go straight. This doesn't work with only one threshold. The robot always ends up in a turn whether left or right, and this is how it always rolls along. When it reaches an intersection, it wants to turn because the value at that point is on one side of the threshold.
This problem was fixed by having two thresholds. They were calculated by having both sensors on light and both on dark. The lower of the two was the low threshold, and the higher one was the high threshold. It didn't matter which produced the higher one because in theory they were both supposed to be the same. As long as the sensor value was lower than the lowest the robot turned left and if it was higher than the highest it turned right. In the event that it fell between the two thresholds, it would go straight.
Table of Content
The Problem And The Solution