Set up the first switch (right side)
The program will check to see if the turret has swiveled too far away from the center. It will make use of the compare switch yet again, this time comparing the number of degrees on motor D to the threshold value that would indicate that it had rotated too far. The mode on the switch block should be set to Motor Rotation | Compare | Degrees.
When the turret swivels to the right of center, the degree count on motor D will be positive. When the turret swivels left, the degree count will be negative. Our robot will need to individually check to see if the turret is too far in each direction, so it will first check to see whether the turret is too far to the right. Therefore, this first switch will only be concerned with the positive direction. We will soon program a second switch that checks in the negative direction.
Set the compare type on the switch to > (type 2). The threshold value that we can say is too far is 250 degrees. Enter 250 into the second input of the switch:
This switch will check to see if motor D has rotated more than 250 degrees to the right of center. If this ends up being true, then the tank will need to make an adjustment to its steering and its turret. We will now program in the code that will make that adjustment.