when robot use the compass to keep moving in straight line.
it take the first angle (angle1) and then each 0.1 second it check the angle again(angle2).
if angle2 is right to angle1 ,then the robot shall take left to keep in line
if angle2 is left to angle1 ,then the robot shall take right to keep in line
the following shows how to check if angle2 is right or left to angle1
for example
27 is forward 207 is backward
1) the first angle - angle1 is 27 , and then angle2 is 40, it means the robot shall change direction to left
2) the first angle - angle1 is 27 , and then angle2 is 10, it means the robot shall change direction to right
3) the first angle - angle1 is 27 , and then angle2 is 350, it means the robot shall change direction to right
337 is forward 157 is backward
4) the first angle - angle1 is 337 , and then angle2 is 20, it means the robot shall change direction to left
5) the first angle - angle1 is 337 , and then angle2 is 357, it means the robot shall change direction to left
6) the first angle - angle1 is 337 , and then angle2 is 310, it means the robot shall change direction to right
140 is forward 320 is backward
7) the first angle - angle1 is 140 , and then angle2 is 200, it means the robot shall change direction to left
8) the first angle - angle1 is 140 , and then angle2 is 100, it means the robot shall change direction to right
9) the first angle - angle1 is 140 , and then angle2 is 350, it means the robot shall change direction to right
240 is forward 60 is backward
10) the first angle - angle1 is 240 , and then angle2 is 280, it means the robot shall change direction to left
11) the first angle - angle1 is 240 , and then angle2 is 200, it means the robot shall change direction to right
12) the first angle - angle1 is 240 , and then angle2 is 10, it means the robot shall change direction to left