Example Code for micro:bit-Motor

Last revision 2025/12/31

This article provides a comprehensive guide on setting up and programming a motor with a micro:bit using a Math & Automatic expansion board, including hardware requirements, wiring diagrams, and Makecode programming instructions.

Hardware Preparation

  • Math & Automatic expansion board for micro:bit, Quantity: 1
  • micro:bit, Quantity: 1
  • Motor, Quantity: 1

Software Preparation

Makecode graphical programming, Mind+ platform.
Makecode Library Address.
About how to install a software library?

Wiring Diagram

No specific wiring required (touch keys are integrated on the board).

Other Preparation Work

Install the Makecode library from https://github.com/DFRobot/pxt-Math-Automatic.
About how to install a software library?

Sample Code

Motor

Result

When key 1 is touched, Motor connected with pin M1 rotate at full speed for 1 second.

Was this article helpful?

TOP