Arduino electronics hardware MIDI

DIY MIDI Percussion Kit – Part 1

Some small projects are interesting because they can enable more than their initial proposition, and the simplicity of producing synthesized sounds using a MIDI interface allows us to experiment with different types of instrument ‘user interfaces’.

In this project I build a flexible software kernel for a DIY MIDI percussion kit that can initially be used with switches and piezo sensors but is easily extensible.

Playing MIDI percussion

MIDI percussion instruments are defined in the General MIDI (GM) specification. GM is a standardized specification for electronic musical instruments that respond to MIDI messages.

To be GM compatible, synthesizers must obey the conventions for program and controller events. Importantly for this project, in GM compatible files, MIDI channel 10 is reserved for percussion instruments only.

The way this works is that events recorded on channel 10 always produce percussion sounds when transmitted to a keyboard or synth module. Each of the different possible notes correlate to a unique percussive instrument – the note number no longer relates to the sound’s pitch but specifies the instrument type. The GM percussive instruments are shown below, mapped to a the notes normally generated by a keyboard.

This means that playing a MIDI percussion instrument is the same as initiating a MIDI note on event appropriate for the instrument on MIDI channel 10. Percussion instruments also do not strictly need a explicit note off event to follow as for a normal note being played.

Input Sensors

Prior to starting the project, the first design decision decision is which sensor(s) should be used to detect ‘hits’ to the percussion instruments.

A switch is good to detect the digital on/off signals for a simple hit, and this will suit many, if not all, percussion instruments. But what if we want some force feedback from the sensor so that the ‘hit’ can incorporate some level of musical expression (eg, MIDI otuput volume)?

A good choice for this type of feedback is a piezoelectric sensor – a device that uses piezoelectric material that generates a voltage when it is compressed. The piezoelectric effect is used to measure changes in pressure, acceleration, temperature, strain, or force by converting them to an electrical charge. These sensors are easily sourced and very inexpensive. The most common are shaped as thin circular disks shown at left.

When an impulsive force (eg, a drumstick strike) is applied to the sensor it responds with a brief voltage spike. The voltage output is proportional to the force applied.

An example spike is captured in the oscilloscope trace below. In this case the bare sensor is struck directly – the voltage spike is close to 60V and lasts about half a millisecond (500 microseconds). The output also has a negative voltage component – about 5V in this case.

Piezo raw output curve

5V Arduino inputs (at least for AVR processors) will not tolerate 60V, nor will they tolerate more than about -0.5V, so the raw signal must be conditioned. The length of the signal could also be too short to be reliably detected by the Arduino code.

One way to do this is using the simple circuit below. The 1MΩ resistor is connected in parallel to the piezo element to limit current (and voltage) produced by the piezoelectric element, while the zener diode ensures that the output voltage is effectively clamped to 5V.

5V Arduino input interface circuit

Making a ‘drum’ style device

To turn the piezo into a drum type instrument, the sensor element needs to be incorporated into something that provides a bigger and bulkier striking surface that allows the musician to play using sticks or their fingers.

As a start, the piezo sensor should be bonded to a larger mass. In this setup, I epoxied the sensor disc to the center of a steel plate 2-3mm thick cut from an old computer case. The central position is used as this is the place where there is a maximum deflection in the plate.

Using the steel plate protects the sensor from direct strikes (they can be fragile) and the additional ‘echo’ vibrations of the plate should extend the signal generated.

A bare steel plate would produce a pinging noise of its own when struck, so it is layered between a dense foam top surface and a foam cushion below. Together they effectively dull the sound of the steel being hit while still allowing reverberations in the steel plate. The figure below shows the different layers in cross section.

Drum layers cross section

The final arrangement for the device is shown below. The lower part of the photo shows the separated parts, as described above, and the top hexagon is an assembled unit. Note the bonded piezo sensor is covered in electrical tape to prevent short circuits. The zener diode and resistor are mounted to the plate (shown below with tape covering temporarily removed for the photo).

Drum device components

Once the sensor is mounted in the arrangement shown , it has a new characteristic curve shown in the oscilloscope trace below. The peak voltage is now 5V and the underswing is around -0.5V, both acceptable values. The mass of the steel plate also prolongs the signal, in this case to around 30 milliseconds, which will be much easier to detect in software.

Piezo drum output curve

As well as being ‘taller’, a harder hit also lasts longer than a soft one. This potentially gives another option for producing louder or softer MIDI sounds.

In the next part we’ll look at the software that turns these sensors into a percussion kit.

9 replies on “DIY MIDI Percussion Kit – Part 1”

Hello Marco. I’ve been using Anvil Studio as a midi file player and using your arduino code with an arduino mega to demux the midi. My problem is with some midi files the notes don’t turn off – once trigged to turn on they stay on. The event list does include the note off event. Do you know what could be causing this? Apparently there are diferent types of midi file but I can’t see the differences between them. My use of your code is very simple – basically if a note is on then turn it on, if the note is off the turn it off. I don’t think the error is in the code since about half the songs I have do play as they should. Any ideas?


I use a very simple scheme to play the midi files, either connected to an electric keyboard to ‘play’ the Arduino MIDI note, or to a dedicated MIDI shield (VS10xx from Sparkfun). The few times I connected to a PC what simple things I did worked fine. Have you tried tracing the MIDI messages on the PC? if it receives the note off message and does not turn off, then it is an issue with Anvil Studio. Also, I am assuming this question does not relate to the topic of this post, as percussion instruments don’t really need a note off – they just play a sound.


Thanks Marco for your prompt reply. Yes, a bit off topic! I have copied the .mid file to your lcd SD card arduino midi player and played the file on that device and the notes are still staying on, so the issue must be with the midi file. I’ll continue to poke around and see if I can find the answer.


One other thing to consider is that a note ON with duration 0 (zero) is treated the same as a note OFF. Some MIDI files use note off, and many use note on/0, This is generally well understood in MIDI circles, but who knows…


Thanks Marco – you have pushed me in the right direction and I have found the answer. I thought all note off commands had a velocity of zero but they don’t. I’ve changed my code to allow for this and it’s now working fine.


Thanks Marco. I have done that…although more by accident than design – they are both powered from the same source!
Thanks also for your arduino projects and libraries that you have generously made available. Without you, people like me wouldn’t be able to enjoy making stuff with arduino.
Kind regards


Hello. I’m wondering if you can answer this question please? I have two arduino, one is playing a midi file and the other is receiving the midi via the tx-rx pins. I have discovered that the communication works without any opto isolation, simply by joining tx of one board to the rx of the other. I understand that opto isolation circuitry is important if I were to introduce a foreign midi device, however, can I safely do without opto isolation if I am only using arduino boards? Thankyou. Kind regards Andrew.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s