This project allows your BBC micro:bit to control micro servo motor positioning. It’s super simple to set up and requires very few parts. For this tutorial we will be using the 180° micro servo motor. This particular servo for recommended to be use by several different projects as it is small and has a decent amount of torque.
Level of Difficultly: Easy
List of Hardware
Install MakeCode Extension
You will notice the extension will show up here.
How Servo Motor Works
- Servo motor works by reading the pulse given to decide the position of the motor.
- Each cycle of the pulse must be 20ms
- Example to control the motor to move to 90 degrees, send a HIGH signal of 1.5ms and LOW signal of 18.5ms continuously to servo motor.
(1) On button A pressed, move the servo motor to 10°. And on button B pressed, move the servo to 90°.
(2) On Start, set servo motor initial position at 90°. Then do the following instruction.
- On button A pressed, move servo motor to 10°. And back to initial position.
- On button A pressed, move servo motor to 170°. And back to initial position.
- On button A+B pressed, move servo motor to 10° –> 90° –> 170° –> 90°
(3) Servo motor moving from 20° to 150°. And at the same time, on micro:bit LED matrix showing “Heart” icon and beating.
Troubleshooting for Servo Motor In micro:bit
- Scenario 1: Servo motor is not moving smoothly or stop or jitter. This is mostly due to the power supply to the motor is not sufficient. This has to do with the maximum amount of current that the BBC micro:bit can handle, using the BBC micro:bit to supply power to a servo has you very close to this limit.
- Solution:Using a battery pack to provide power directly to the servo and only using the BBC micro:bit to supply the control signal to the servo is the best way to protect your BBC micro:bit from harm and to ensure that you are getting the full amount of torque from the servo.
- Scenario 2: Servo motor jam. Every servo motor have the standard level of operating voltage and usually is 4.8V above. (But for this tutorial, we will be using customize servo motor which run in 3V.) Due to the power different of servo, the servo motor might will get wrong signal because of signal power different and result in motor move over limit and jam.
- Solution:Try not to control servo motor to move to 0° and 180° to prevent it from out of the range due to the power different.