For a BOE Shield-Bot to follow a leader-object, it has to know the rough distance to the leader. If the leader is too far away, the sketch has to be able to detect that and move the BOE Shield-Bot forward. Likewise, if the leader is too close, the sketch has to detect that and move the BOE Shield-Bot backward. The purpose of the sketch is to make the BOE Shield-Bot maintain a certain distance between itself and the leader-object.
Some Control System Vocabulary
When a machine is designed to automatically maintain a measured value, it generally involves a control system. The value that the system is trying to maintain is called the set point. Electronic control systems often use a processor to take sensor measurements and respond by triggering mechanical actuators to return the machine to the set point.
Our machine is the BOE Shield-Bot. The measured value we want it to maintain is the distance to the leader-object, with a set point of 2 (for zone 2). The machine’s processor is the Arduino. The IR LED/receiver pairs are the sensors that take distance value measurements to the leader-object. If the measured distance is different from the set-point distance, the servos are the mechanical actuators that rotate to move the BOE Shield-Bot forward or backward as needed.