logo

Using servos and sound at the same time

QUESTION

I want to use servos and sound at the same time.
When I use servos and sound, they seem to interfere

ANSWER

Yes, this is how the micro:bit works. It is not possible to reliably use the sound playback (music or pitch) and servos at the same time. This is because the PWM generation on the micro:bit uses a single hardware timer, so the period of all PWM generation must be the same across all pins.

WORKAROUND

One way to work around this problem is to use two micro:bits and use the radio feature to send messages between the two. Then use micro:bit A for driving the servo, and micro:bit B for generating the sound.

Another workaround would be to put the servo pins into a stable state when playing sound.

Here is an example:

0 found this helpful
All for Joomla All for Webmasters