Make It Move

In this activity, you'll learn about servo motors, how to connect one to your micro:bit, and use MicroBlocks to control its movement.

Collect Materials

assorted materials for the activity
  1. Gather Materials

Get Started

Motors are one way to add movement to your projects. There are many different types of motors, including one called a servo motor.

A servo motor provides position control, so it can be told to move into an exact spot. Its position can be selected from 0 to 180 degrees.

  1. Insert your micro:bit into the Bit Board, pins facing down.
  2. Connect a servo to the pins on the Bit Board, making note of which pins. Use the following image as reference for setup.
The direction you plug things in matters! The LEDs on the micro:bit should be facing out when plugged into the Bit Board. The colors of the servo wire should match the colors of the pins on the Bit Board. And if you are using the battery pack, the red wire should be plugged in to the "+" side and the black wire should be plugged in to the "-" side.
labeled diagram on how to set up microbit with Bit Board
  1. Add the servo library in MicroBlocks by selecting Library, and then Servo.ubl.
cartesian coordinates with 0 degrees, 90 degrees, and -90 degrees labeled

Control the servo motor by using the servo motor blocks. After adding the servo library, you'll have the following blocks available:

servo blocks, including set servo position, set servo speed, and stop servo

Add Movement

Now that you've set up your micro:bit and servos, make your first movement. Use the set servo to degrees block to make the servo move, and change the sign (positive and negative) to switch the direction.
  1. Make your servo move using at least two blocks.

In this example, the servo motor moves twice with a wait block to add a pause between movements. This script starts by pressing the A button.

code blocks that include set servo to degrees blocks and wait blocks

Add Another Type of Movement

There are many ways to make a servo move: big or small, quick or slow, with pauses or rapid succession, the choice is yours!
  1. Create a second servo movement.

This example uses the B button to reset the servo's position.

reset the position of the servo arm after the first movement
Now that you've made two different movements with your servo, consider making something more complex using different micro:bit inputs. Or add more than one servo to your Bit Board to control multiple motors simultaneously.
In this activity, you learned how to connect a servo motor to your micro:bit and make it move in MicroBlocks.