Keeping the beacon in sight

For the tank to follow the beacon, it is imperative that the tank keeps it within the range of its infrared sensor's sight at all times. Also, the turret on the tank can only rotate so far before it runs into its mechanical limit.

The final part of the program allows the tank to keep the beacon in sight while also preventing the turret from over-rotating. It will check to see if the turret has turned too far from the center; if it has, the tank will make a sharp turn to center the beacon in its field of view and reset the turret to a central position.

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.