I’ve made a few simple projects to turn a BBC micro:bit into (sort of) musical instruments.
First, I made a simple arpeggiator. The micro:bit is, of course, only capable of playing 1 note at a time, but take 3 notes from a chord and break them apart and you get something that sounds… like music:
You can try this for yourself even if you don’t have a micro:bit, using the simulator: https://makecode.microbit.org/_XRogJF6kzHWE
Next I tried to make a theremin-type instrument, controlling the pitch of the tone being played by changing the physical pitch (tilt) of the micro:bit:
Here’s the code that makes it work:
And finally, I used the micro:bit’s magnetometer: the stronger the magnetic field detected, the higher the pitch of the sound:
You can’t really use the magnetometer in the simulator, but here’s the code for the project – only the ‘forever’ block is important, the buttons were used when testing it.
If you make some noise with your micro:bit, I’d like to know about it!