chipKIT: TouchClamp click drum machine


This blog post is more than two years old.

Touch clamp drum machine: the software

And now we come to the fun part: the software.

For the TouchClamp click I used the MPR121 library from Adafruit, with a small change: in the Adafruit_MPR121.cpp file.

has to be changed to:

Without this little change there’s no stop condition sent after writing data to the MPR121.

The MP3 code for real-time MIDI is based on the MP3_Shield_RealtimeMIDI.ino. It’s the same code I used as a source of inspiration when I created the Flip & Click Theremin, and I know it works fine.

There are several particularities in the way percussion instruments work in VS1053. First, the instrument bank is 0x78. One must select an instrument, no matter which one. There are no notes, each note code corresponds to a percussion instrument – a list of percussion MIDI codes can be found on So, to hit the bass drum one must play note code 36. The snare drum is 38. Low tom is 43, mid tom is 47 and high tom is 50. The ride cymbal is 51, and the pedal hi-hat is 44. The open Hi-hat is not implemented. I have mapped it to the H button on the TouchClamp click, but is very hard to play it this way.

With the above considerations, the code is:


1 2 3

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.