Skip to content
Learnearn.uk » Microbit Unit Home » Topics » Microbit how to control servos

Microbit how to control servos

What is a standard servo?

standard servo demo gif

A standard servo is a device used to move components by  a fixed angle.

  • They can only rotate with a fixed angle limit, usually between 90 and 120 degrees
  • The analogue value that the servo is given controls what angle the servo is to be set at.

They are commonly used in:

  • Radio controlled cars to steer
  • Radio controlled planes to set the rudder and wing flaps

What is a continuous servo?

continuous servo

A continuous servo is looks similar to a standard servo, however it doesn’t have a limited range of movement. This means it can used to

  • No limited range of movement
  • You can control the exact position, only the rotation speed.

Common uses:

  • control wheels on robots
  • mini winches on models.

Want to to know more about how they work? Take a look at this article.

Microbit with servo connected using banana plugs

Standard Servos

  • White wire – signal wire, connect to GPIO port 0 or 1
  • Red wire – 3v wire, connect to 3v on the Microbit
  • Black wire – Ground, connect  to GND.

Continuous Servos

  • Orange – Signal ( Connect to GPIO 0 or 1)
  • Red – 3V Input
  • Brown/black – Ground GND

 

standard servo demo code

Write analogue out

  • 20 farthest turn angle anticlockwise
  • 90 farthest turn angle clockwise

Note

These values are approximate through trial and error but they should get you close enough to what you need. Depending on the servo the values might need tweaking for the correct angles – have a play and find out!

microbit continuous servo with stop code

The continuous servo, like standard servos, take an analogue value for an input, but this time the value given is used to control the speed and direction, not the position of the arm.

Analogue output

  • 20 to 70 Anticlockwise
  • 0 Stop
  • 80 to 150 Clockwise

Note

These values are approximate through trial and error but they should get you close enough to what you need. Depending on the servo the values might need tweaking if you want to turn at slow or fast speeds!

continuous servo analogue write intsructions

 

Challenge -

Challenge 28 - Servo direction control

When the A button is pressed:

  • spin the motor clockwise

When the B button is pressed

  • Spin the motor anticlockwise

When both buttons are pressed:

  • Turn off the motor.

Challenge -

Challenge - Tilt the Microbit servo speed control

Get the Microbit to change the speed and direction of the motor, depending on the tilt of the Microbit.

Challenge -

Challenge -