Example Code for micro:bit-4-way Motor Drive

Last revision 2026/01/14

This article offers a step-by-step guide on using the micro:bit V2 and MBT0042 expansion board to control four motors. It covers hardware and software setup, including links to MakeCode programming platform and sample code, making it an ideal resource for DIY enthusiasts looking to enhance their micro:bit projects.

Hardware Preparation

  • micro:bit V2
  • MBT0042 expansion board
  • 4 motors

Software Preparation

  1. Enter the MakeCode programming platform in browser: https://makecode.microbit.org/
  2. Create a new project and name it.
  3. Load in the program library of xia_mi board: click “setting”, and “expansion” in turn, then paste this link in the search box: https://github.com/DFRobot/pxt-DFRobot_xia_mi_Board.

Sample Code

MakeCode Program Link: https://makecode.microbit.org/_eR62rrYvCfyo

Motor

Was this article helpful?

TOP