Robot intelligent : Suiveur de ligne – Logique
Overview
So far, we’ve made a body for our robot and given him a brain AND an enemy-hunting upgrade. But we should know the logic behind it. Let’s see how our robo-comrade will hunt the bad guys down.
The logic is pretty simple. What is more, you already know the part concerning the robot’s motion. Refer to the previous mission’s training for the logic and script for the same. All that remains is to decide how to make the robot follow your enemy.
Logic
How, or rather when the robot follows anything depends on the state of the two sensors. If both sensors are ON, that means the object is in front; the robot should move in the forward direction.
If only the sensor on the right is ON, it means the object is in the right, and hence the robot should turn right.
Similarly, when the object is to its left, only the sensor on the left will be ON and the robot should turn left.
If there is no object within 10cm, both sensors will be OFF. Therefore, the robot should stop.
Flow Chart
Below is the flowchart for the above logic:
