Micro:bit Monday: Servo:bit
Need precise control in a project? Then you need a servo.
A servo?
Yeah, servos are precisely controlled motors that can be set to move to a specific angle. So if we need to move an arm on a robot, rotate a sensor or move a LASER emitter to keep the cat entertained..A servo is our go to piece of kit.
So how does a servo work?
Servos connect to a device using three wires. 5V power, GND and a control / signal wire. The signal wire is used to send a series of pulses using Pulse Width Modulation (PWM) and the width of a pulse controls the position of the servo arm. With a minimum pulse width of 1ms the servo will go to 0°, a neutral position (90°) is set by sending a 1.6ms pulse. The maximum position of 180° is set by sending a 2ms pulse.
That sounds hard!
PWM is not that difficult, thanks to libraries that abstract the complex information away from the user, enabling us to issue a command and watch the result.
So back to Servo:bit
Servo:bit from 4tronix is a micro:bit add on board that offers connections for up to 16 servos! Yes that is a lot of servos.
I connected three servos (2 x cheap SG90 and an MG90S which is a more expensive servo) and tested them with a little micro:bit makecode.
And this is what happened.Quick mess around with @4tronix_uk Servo:bit for @microbit_edu pic.twitter.com/cYeP1G7jR4
— biglesp (@biglesp) January 6, 2020
Is there an extension for Servo:bit?
Yes! Go to Extensions (the cog in the top right) and search for servo and you will find the correct package.
We then get these blocks to control all of the attached servos.
What are the specifications for Servo:bit?
Measuring 65mm by 30.5mm the Servo:bit is the same size as Drive:bit, and a Raspberry Pi Zero W.
Power can be supplied via micro USB.
Or via a screw terminal.
Both power inputs supply power to the micro:bit, nice!
Note that a maximum of 6V can be supplied and that micro USB AND screw terminal power should NOT be used at the same time.
As well as offering up to 16 servos, Servo:bit has standard GPIO access, so we can attach buttons, sensors etc and use those to trigger our servos.
If we need to mount Servo:bit in a case / chassis etc then the four M2.5 screw holes offer plenty of support opportunities.