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 ...

Get Building Smart LEGO MINDSTORMS EV3 Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.