Example Code for micro:bit-Motor Control

Last revision 2026/01/14

This article provides example code for controlling motors using micro:bit and Maqueen Lite, with detailed instructions on hardware setup and programming using MakeCode, enabling movements like forward, backward, and turning.

Hardware Preparation

  • Maqueen Lite x1
  • micro:bit V1/V2 x1
  • MicroUSB cable 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

  1. Load MakeCode Graphical Library for Maqueen as described in the previous example.

Sample Code

Code idea: set the same direction and speed of the left and right motors to realize the robot car moving forward or backward; set the same direction and different speed of them to realize the left and right turns.

Code URL: https://makecode.microbit.org/_Ms2Ea7foPKXA

Code File: maqueen4.hex

Code Screenshot:

Result

Maqueen repeat: move forward 2 second, turn left 2 second, turn right 2 second and move backward 2 second.

Was this article helpful?

TOP