Here is the improved program that I would be prevented off the track.
Since increasing the process too much it becomes the blockbuster.
[DOWNLOAD] Created Program 5(for the NXT software)
This program must have three variables. These are all called "logic" will contain either of the two types of "positive" and "fake".
The program is so long, I will split into three.
This is the first 1/3.
After the initialization of variables, the motor make the right turn or left turn.
This is the second 2/3.
Detection has been doing on white or black. It will be "positive" at the end of the flag is detected. The timer switch will judge the track is on or off. If you could not detect the boundaries of the black/white to within one second, the loop will be terminated.
In this way, it should no longer keep looking for a black / white.
This is the last 3/3.
Reverse the flag of detection white竊絶・black. And, when the white detection is finished, invert the flag of the left and right turning.
Now it can move zigzag on the line.
I tried to run the program. If it slides off the track, the direction of the turn will be returned automatically.
However, it is not enough for returning, in many cases could not be returned to the line again. It is necessary to devise more. I tried to shake the nose from side to side, the efficiency of the move does not seem to improve much. I think it is so hard to make an accurate robot.
I will introduce the idea to further improve the robot. Please refer for next time.