USB MIDI drum pad controller
Build it step by step
0 of 6 doneWire one pad
Connect a piezo, 1 MΩ resistor and zener to A0 and print the readings while tapping.
Set the threshold
Choose THRESHOLD just above the noise when untouched.
Add MIDI
Upload the sketch and check the Leonardo appears as a MIDI device on your computer.
Add the other pads
Repeat the wiring for A1 to A3.
Add the knobs
Wire the four potentiometers to the knob inputs.
Map in your DAW
Assign CC 20 to 23 to effects such as filter or reverb.
How do you build an USB MIDI drum pad controller?
An Arduino Leonardo shows up as a USB MIDI device, with piezo pads for drums and knobs for effects. You need Arduino Leonardo, Piezo disc buzzer element × 4, Resistor 1 MΩ × 4, Zener diode 5.1 V (1N4733A) × 4, Potentiometer 10 kΩ × 4 and USB A to micro-USB cable (data). It takes 6 steps and about 180 minutes.
- Level
- Intermediate
- Time
- About 180 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Leonardo × 1
- Motors & ActuatorsBuy
- PassivesBuyResistor 1 MΩ × 4
- SemiconductorsBuy
- PassivesBuy
- Cables & WiresBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Each piezo disc (4 pads) | Leonardo A0, A1, A2, A3 and GND | Signal and ground |
| 1 MΩ resistor across each piezo | Piezo signal and GND | Bleeds the charge away |
| 5.1 V zener across each piezo | Cathode (band) to the piezo signal, anode to GND | Protects the input from hit spikes |
| Potentiometer 1 outer pins, wiper | 5V and GND, wiper to A4 | Knob 1 |
| Potentiometer 2 outer pins, wiper | 5V and GND, wiper to A5 | Knob 2 |
| Potentiometer 3 outer pins, wiper | 5V and GND, wiper to D4 (analog A6) | Knob 3 |
| Potentiometer 4 outer pins, wiper | 5V and GND, wiper to D6 (analog A7) | Knob 4 |
| USB cable | Leonardo USB port | Power and MIDI to the computer |
Code
Arduino IDE, board "Arduino Leonardo" (its ATmega32u4 can act as a USB MIDI device; an Uno or Nano cannot). Install the "MIDIUSB" library. Use a DAW or a free drum plugin and select the Leonardo as a MIDI input. Mount each piezo disc under a firm foam pad on a rigid plate so a hit makes a sharp spike. A zener across each piezo and a 1 MΩ resistor keep the analog pin safe from the brief high voltage of a hard hit.
Runs on a virtual Arduino Leonardo in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <MIDIUSB.h>
const byte PADS[4] = { A0, A1, A2, A3 };
const byte NOTES[4] = { 36, 38, 42, 45 }; // kick, snare, closed hi-hat, tom
const byte KNOBS[4] = { A4, A5, A6, A7 }; // analog inputs on D4 and D6 for the last two
const byte CCS[4] = { 20, 21, 22, 23 };
const int THRESHOLD = 40; // ignore noise below this reading
const unsigned long LOCKOUT = 60; // ms, stops a hit retriggering
unsigned long lastHit[4] = { 0, 0, 0, 0 };
int lastKnob[4] = { -10, -10, -10, -10 };
void noteOn(byte note, byte vel) { midiEventPacket_t e = { 0x09, 0x90, note, vel }; MidiUSB.sendMIDI(e); MidiUSB.flush(); }
void noteOff(byte note) { midiEventPacket_t e = { 0x08, 0x80, note, 0 }; MidiUSB.sendMIDI(e); MidiUSB.flush(); }
void control(byte cc, byte value) { midiEventPacket_t e = { 0x0B, 0xB0, cc, value }; MidiUSB.sendMIDI(e); MidiUSB.flush(); }
void setup() {}
void loop() {
for (byte i = 0; i < 4; i++) {
int v = analogRead(PADS[i]);
if (v > THRESHOLD && millis() - lastHit[i] > LOCKOUT) {
int peak = v;
unsigned long t = micros();
while (micros() - t < 4000) { int r = analogRead(PADS[i]); if (r > peak) peak = r; } // catch the peak of the hit
byte velocity = constrain(map(peak, THRESHOLD, 900, 20, 127), 1, 127);
noteOn(NOTES[i], velocity);
delay(30);
noteOff(NOTES[i]);
lastHit[i] = millis();
}
}
for (byte k = 0; k < 4; k++) {
int v = analogRead(KNOBS[k]) / 8; // 0 to 127
if (abs(v - lastKnob[k]) > 1) { control(CCS[k], v); lastKnob[k] = v; }
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Tap a pad softly | Quiet drum note |
| Tap hard | Louder note (higher velocity) |
| No hit | No notes sent |
| Turn a knob | A control change message appears in the DAW |
If it does not work
No device appears
You need a board with native USB, such as the Leonardo.
Double triggers
Raise the lockout time or threshold.
Pads always on
The zener or resistor is missing, or the threshold is too low.
Crosstalk between pads
Isolate the pads with foam and raise the threshold.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the USB MIDI drum pad controller?
Arduino Leonardo, Piezo disc buzzer element × 4, Resistor 1 MΩ × 4, Zener diode 5.1 V (1N4733A) × 4, Potentiometer 10 kΩ × 4 and USB A to micro-USB cable (data).
How long does the USB MIDI drum pad controller take to build?
About 180 minutes for a intermediate maker, in 6 steps.
How do I know the USB MIDI drum pad controller works?
Tap a pad softly: Quiet drum note. Tap hard: Louder note (higher velocity). No hit: No notes sent.
No device appears: what should I check?
You need a board with native USB, such as the Leonardo.
Double triggers: what should I check?
Raise the lockout time or threshold.
Pads always on: what should I check?
The zener or resistor is missing, or the threshold is too low.
Crosstalk between pads: what should I check?
Isolate the pads with foam and raise the threshold.
