Example Code for micro:bit-Auto Line-tracking
Last revision 2026/01/14
The article offers a detailed tutorial on implementing auto line-tracking with micro:bit and Maqueen Lite, covering hardware and software setup, wiring, and coding using the MakeCode platform to ensure precise control of the robot car along a black line.
Hardware Preparation
- Maqueen Lite x1
- micro:bit V1/V2 x1
- MicroUSB cable x1
- Line-tracking Map x1
Software Preparation
- Programming Platform: makecode
- Libraries: maqueen, neopixel
Wiring Diagram
No additional wiring is required except inserting the micro:bit into Maqueen Lite.
Other Preparation Work
- Load MakeCode Graphical Library for Maqueen as described in the previous example.
- Prepare a line-tracking map.
Sample Code
Effect: the two line-tracking sensors work at the same time to make sure the robot car run along the black line.
Code URL: https://makecode.microbit.org/_4rACHK3e2eeX
Code File: maqueen8.hex
Code Screenshot:

Result
A successful line-tracking run is done, but due to the small map, the car is set to run at a slow speed.
Additional Information
The line-tracking map in the kit is used here.

Was this article helpful?
