TS-DET1 – micro:bit keypad synth with detuning

It feels rewarding to use a device by leveraging its unique traits, and the BBC micro:bit has two features that are rarely found onboard other microcontrollers: a LED matrix and gyro sensor.
So, I decided to design a circuit that detects and displays tilting, and uses it to alter the pitch of the notes being played.
The result is a quirky musical toy, surprisingly expressive and with a personality of its own.

The input part of the instrument is a 5×5 matrix of tactile push buttons, each one paired with a diode to prevent ghosting (ghosting as in false input. Diodes won’t solve unrequited love issues.)
Some of the pins used as key inputs are shared with the LED matrix, requiring to continuously switch the display off and back on, which results in a noticeable flicker.
I connected the audio signal output of the micro:bit to a quad op-amp to drive two small speakers. If you’re building your own TS-DET1, you could use a single 8Ω speaker and a power op-amp, like the LM386.

I did some research and I decided to add a passive low pass filter before the amplification stage. It’s a way to soften the harshness of the pure square waves, but I also did it because I know that children are more sensitive to high frequencies than adults, and do not like beeps that are too high-pitched.

Comparison of two recordings, one with and one without the low pass filter

The whole circuit is powered by two AAA batteries and is fitted into a plastic case for playing cards.

The prototype in these pictures is now in the small hands of its new owner, and I do not plan to create new iterations. However, if I were to do it again, I would try to skip micropython and micro:bit’s music module, trying to use C instead to set my own timers to control the PWM and produce the different notes.
Also, the two unused tilt axes could be used to control volume and octave shift.

Download the source code for this project: github.com/TuriSc/TS-DET1