Example Code for Quick Line Tracking

Last revision 2026/01/20

The article provides an example code for the Maqueen Plus V3 robot to follow a black line using a built-in line-tracking algorithm, allowing micro:bit to handle additional tasks like obstacle avoidance and music while showcasing vehicle lights with seven colors and customizable RGB LED settings.

Introduction

Maqueen Plus V3 features a built-in line-tracking algorithm in its底层 chip, enabling simplified black-line following with a single block. This reduces programming complexity and frees the micro:bit for concurrent tasks (e.g., obstacle avoidance, music).

  • Vehicle lights show 7 colors: red, green, yellow, blue, purple, cyan, white.
  • Bottom RGB LEDs (0–3) are set to red individually.
  • Line-tracking speed: Level 1 (slowest) to 5 (fastest).
  • Once enabled, tracking runs continuously in the background until disabled.

Hardware Preparation

  • Maqueen Plus V3
  • Printed black-line track
  • USB cable

Software Preparation

  • MakeCode with Maqueen Plus V3 extension

Wiring Diagram

All sensors and actuators are pre-wired on the Maqueen Plus V3 mainboard.

Sample Code

View on MakeCode

Key Blocks Used:

  • Maqueen Plus V3.lineTracking(Level.One)
  • Maqueen Plus V3.vehicleLight(...) with multiple color settings
  • Maqueen Plus V3.setBottomRGB(LEDIndex.All, R, G, B)

Result

  • The robot automatically follows a black line on a white surface.
  • Vehicle lights cycle through seven predefined colors.
  • Bottom RGB LEDs remain solid red during operation.
  • Line tracking continues until explicitly stopped in code.

Was this article helpful?

TOP