Simple line follow program
Upload the program to Arduino
As black can absorb infrared light, then in consideration of Example 21 Value of the line-follower sensor, and we can let mBot identify a black track on a light-color surface or let mBot identify a light color track on a black surface .
Here we take a black track on a light color surface for exmaple to explain how to use a line-patroling sensor to make mBot move along a track.
The following introduces four situations where mBot is relative to the black line, which can be dealt with using the following strategies:
1, if it is on the black line, it keeps moving forward;
2, if it deviates from the black line, it turn left or right in time to keep itself on the line;
3, if it is not on the black line, it turns back to find the black line.
For the above four situations, the program can be the example:
The line-patroling sensor is the best to identify pure white or black surface without reflection. Commonly you can use a black electrician tape to make a patroling line on a light color surface to achieve the best effects.
|Task 1||Change the speed of mBot when it is moving forward or turning. Observe mBot’s line patroling effects.|
|Task 2||Let’s think: In Situation 4, what strategy can mBot use to find the black line.|
Attached – Line-patroling sensor structure diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.