Tilt Servo Control

In this animation, both the micro:bit LED matrix display and the servo horn point upward as the rest of the setup is rotated.  This is an example of “tilt controlling” the servo with sensor measurements from the micro:bit module’s built-in accelerometer.  (View in higher resolution .mp4 here.)

In this activity, you will:

  • Test a tilt controlled servo script that makes the servo point up as it is rotated with the micro:bit.
  • Use the terminal to become more familiar with the calculations the script performs to make the servo horn point up.
  • Adjust the script so that when the servo is held still, the servo horn’s direction follows the tilt of the micro:bit.

Before you start:

These three activities (total of 14 web pages) provide a guided micro:bit accelerometer tour and also have script elements that will be reused in this activity.  Although they are from the cyber:bot series, a cyber:bot is not required; you will only need a micro:bit and USB cable for these three warm up activities:


Same as Connect and Test the Servo.


Also the same as Connect and Test the Servo.

Important: Make sure to orient the servo by the micro:bit as shown in this diagram.  With the horn in the 90° position, it should be pointing to the left.  You will be holding the servo against the edge of the I/O adapter as you rotate it.