"It’s Here! The BFCM Sale of the Year – Grab Your Favorites!"

AI Lens Line-tracking car

1.Materials Required

micro:bit * 1

Nezha Expansion Board * 1

Planet X series-AI Lens * 1

Planet X series- Motor Brick * 2

RJ11 wire * 1

n * Bricks

2.Hardware Connection

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.

3.Bricks build-up

4.Programming

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%.

Link: https://makecode.microbit.org/_XdtPA8Hepc44

5.Result

The car drives along with the black line. (Note: the background color must be pure white for this function)

Leave a Reply

images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
images
Children’s Programming Education is the Future Trend
images
Technical verification! Nezha series products can complete WRO competition tasks
images
Let's take part in the Ceremony of the New Factory of ELECFREAKS together!
images
Bluetooth Bee(HC-05 and HC-06) User Guide
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Monthly Archive