Example Code for micro:bit-Drive Servo

This article offers example code and instructions for driving a servo using micro:bit, including hardware and software preparation, wiring diagrams, and sample code for adjusting servo angles with button presses.

Software Preparation

Graphical block software library: https://github.com/DFRobot/pxt-motor

Sample Code

Drive Servo

Result

When the A is pressed, set the angle of servo to 180°, when the B is pressed, set the angle of servo to 0°.

Was this article helpful?

TOP