DFRobot MBT0021-EN Manual - Página 8
Procurar online ou descarregar pdf Manual para Robótica DFRobot MBT0021-EN. DFRobot MBT0021-EN 18 páginas.
After the above procedure is executed, you will find that the car always turns in one direction
after encountering an obstacle. Below we will improve the program as follows, let the car
encounter obstacles and randomly choose a turning direction to continue driving.
In the program, a module that generates integers randomly is used to randomly produce 1 or 2. If
it is judged that the random number is 1, then turn right, if the random number is 2, then turn left.
Program Link:
https://makecode.microbit.org/_JyKALkaeh5j5
6-4 Line-tracking Robot
The function of the following program is: put the car on the circular black line map, the car will
use the three line-tracking sensor probes set at the bottom to detect whether the car is driving on
the black line. If it deviates from the black line, the car will correct its driving direction in real
time so that the car will always follow the black line.
There are 5 line-tracking sensor probes in Maqueen Plus V2. In this program, three probes, L1,
R1, and M, are used to detect black lines. L2 and R2 are not used yet.
When the line-tracking probe detects a black line, the output value is 1, and when it detects a
white line, the output value is 0. With this feature, three line-tracking sensors can be used to
detect the black lines, and the status of multiple probes can be used to determine the position of
the black line in real time and how the car should turn to correct deviation.