Example Code for micro:bit-Vibration Motor

Last revision 2025/12/31

This article provides a detailed guide on setting up a vibration motor with a micro:bit using Makecode, covering hardware and software preparation, wiring instructions, and sample code execution.

Hardware Preparation

  • Math & Automatic expansion board for micro:bit, Quantity: 1
  • micro:bit, Quantity: 1
  • Vibration 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

Vibration Motor

Result

When key 3 is touched, vibration motor vibrates for 1 second.

Was this article helpful?

TOP