上QQ阅读APP看书,第一时间看更新
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.