AI Lens Line-tracking car
micro:bit * 1
Nezha Expansion Board * 1
Planet X series-AI Lens * 1
Planet X series- Motor Brick * 2
RJ11 wire * 1
n * Bricks
Connect the micro:bit to Nezha expansion board, and connect the AI Lens to the IIC port on the Nezha expansion board with RJ11 wires, then connect the two motors to M1&M2 accordingly as the picture shows.
Go to the MakeCode programmming page https://makecode.microbit.org/#editor
Add planet X package and click extensions on the menu of the settings on the right upper side.
Search with PlanetX in the dialogue box to add the package.
Add Nezha package in the same way.
After finishing the above steps, now we need to programme:
Initialize the AI lens via IIC port in the On start brick.
Set the AI Lens in the line-tracking mode.
Get one image from the AI Lens in the forever brick and set the motor M1 at speed 10% if the black line in the image being detected deviating to the left; and set the motor M1 at speed 60% if the black line in the image being detected deviating to the right side. Or set both the speed of M1 and M2 at 60%.
The car drives along with the black line. (Note: the background color must be pure white for this function)
Share this post
About the Author