Example Code for micro:bit-Control Servo via Angular Rotation Sensor

Last revision 2026/01/14

Explore the process of controlling a servo with a micro:bit using an angular rotation sensor, including hardware preparation, MakeCode programming, and sample code.

Hardware Preparation

  • micro:bit V2
  • MBT0042 expansion board
  • 9g servo

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/_TVmLvAXTq2v5

Angle

Was this article helpful?

TOP