Example Code for micro:bit-Line-tracking

Last revision 2026/01/14

This article details how to use micro:bit with Maqueen Plus V2 for line-tracking, offering sample codes and guidance on creating a line-following car using built-in sensors.

Hardware Preparation

  • Maqueen Plus V2
  • micro:bit V1/V2
  • Line-tracking Map (included)

Software Preparation

Wiring Diagram

No additional wiring needed; line-tracking sensors are built-in.

Other Preparation Work

  1. Complete the Quick Start Guide steps.
  2. Place the car on the line-tracking map.

Sample Code

Basic Program Link: https://makecode.microbit.org/_KhA1VvMi70rp

Improved Program Link: https://makecode.microbit.org/_WVc5uwLsq9xE

Result

Basic: Car follows the black line using 3 sensors.
Improved: Car uses 5 sensors to return to the line if it deviates.

Additional Information

Ensure the line-tracking sensors are calibrated (see Getting Started section).

Was this article helpful?

TOP