Case 03: Line Tracking
Purpose
- Programme to set the TPBot driving along with the black line.
Material
- 1 x TPBot
Software
Programming
- Click "Advanced" to see more choices in the MakeCode drawer.
- We need to add a package for programming. Click "Extensions" in the bottom of the drawer and search with "tpbot" in the dialogue box to download it.
Sample
- Judge the status of the line-tracking sensors: if the black was detected on the left, set the speed of the left wheel in 0 and the right in 40; if the black was detected on the right, set the speed of the left wheel in 40 and the right in 0.
Link
- Link: https://makecode.microbit.org/_Tc45z4cwMaLE
- You may also download it directly below:
Conclusion
- TPBot drives along with the balck line.
Exploration
FAQ
Q: The car does not work with the code in the wiki. A: It should be the batteries that are lack of power, please try to fix it by adding the value of the speed in the code.