Homemade Electronic Drum Kit With Arduino Mega2560





Introduction: Homemade Electronic Drum Kit With Arduino Mega2560

This is my Arduino Project. How to build an e-drum kit with Arduino?

Hello dear reader!

-Why doing such a Project?

First of all because if you like these kinds of things, you will enjoy the work process really much. Second, because its really cheap compared to real e-drum kits and you will be able to save a huge quantity of money. Anyway, lets move on to the main part of this article.

Step 1: Materials


- Wood.

You will need different measures of wood. I used 16mm and 10mm MDF for the Drum pads and then 5mm plywood for the Cymbals.

I highly recommend MDF for making this project because of its ease while working with it

- Arduino Mega.

I used an Arduino Mega 2560 because I included 9 components. Otherwise you can use an Arduino UNO, which is cheaper.

- USB m/m cables.

To connect the sensors to the Arduino board you will need either USB or Jack cables. Jack cables are better in this case, but you will save money if you get the USB ones. Apart from the cables you will also need to get their respective female connectors.

- EVA rubber. (Commonly known as swimming pool floor)

- Sensors. Piezos and a photocell.

The piezos are the sensors for the Pads and Cymbals. The photocell will work as a HiHat pedal.

- Resistors, Protoboard/Breadbord, electric cable, pin Headers.

- MIDI connector and MIDI to USB cable.

- Screws, nuts and butterflies

- Pet screen

- *E-drum structure


- Jig Saw

- Sander / Sand paper

- Drill

- Screwdrivers

Step 2: Drum Pads

Use the Jig Saw to cut a basic shape from the 16mm MDF. This will be the bottom of our Pads. I recommend you to cut them with a regular shape so it looks better in the end. After this, cut a ring from the 16mm MDF with the same size as the bottom of the Drum pads.

Once you have cut as many bottoms and rings as you need, it is time to move on to the next step.

Step 3: Head Membrane

To attach the head membrane to the pads, you will need to cut two more rings, which will be in charge of holding and tensing the membrane.

The first membrane-hoop needs to be from a smaller MDF than the bottom and first ring of the Pads. It has to be a bit thinner than the first pad, but you can only cut from the inside part, so that the outside edge of the membrane-ring matches with the outside edge of the first ring.

The second membrane-hoop has to be higher than the first membrane-hoop and his inside edge has to coincide with the inside edge of the first ring.

Once you have cut these two hoops, it is time to cut the membrane from our pet screen. You can choose the number of sheets of pet screen for making the membrane. I used 4 sheets for each membrane so I could play harder without breaking them.

With a hot glue gun, draw the shape of the first membrane-hoop, leaving some space between the hoop and the glue, on the four sheets put together earlier, so that they stay fixed. After that cut the membrane around the hot glue to get your first membrane. Repeat the process, as many times as membranes you want.

To tense and fix the membrane to the membrane-hoops, you will have to drill some holes through the first membrane-hoop and the pet screen, as the picture above shows. The membrane will go situated between the two membrane-hoops.

Step 4: Finishing the Drum Pads

Now it is time to screw the whole Pad together. Use the screws, the washers and the nuts. You can see the finished Pad on the picture below. Don’t screw the bottom now! You have to put the sensors first!

The sensor goes on the bottom of the Pad and “connected” to the membrane through a trigger pyramid. Anyway, you can adapt the Piezo-Sensor however you want.

Step 5: Cymbals

The cymbals are made out of a sheet of 5mm plywood and the EVA rubber. The EVA rubber is used to decrease the noise while hitting the cymbal.

You will have to cut (3) triangles of the plywood. And drill 2 holes on them. One of the holes is for the stick of the structure and the other one works to get the cables from the Piezo-Sensor through.

Step 6: Hi-hat Pedal

For making the Hi-hat pedal you will need a photocell and a left foot sandal. Remove the band of your flip-flop and put an elastic one instead.

Drill the sandal through and make some space for the sensor on the front part of the bottom of the sandal.

After that, you will have to weld the cables to the photocell and to the connector (usb/ Jack) situated in the back of the sandal.

Step 7: Kick / Bass Drum Pedal

For making the Kick pedal there are many options.

If you want to do my Kick pedal variation, you need some Wood, screws, some EVA rubber and finally, the Piezo-Sensor

Make an inclined wood structure and put the piezo sensor on it. Cover then the whole pedal with the rubber to isolate the sensor.

Step 8: Circuit

Every component should be now connected to a cable (usb/jack). You will have to connect those cables to a female adaptor and then to the breadboard.

Sensors usually need to be connected to the arduino board through resistors.

The Piezo-Sensors need a 1MOhm resistor between the analog input and the ground pin. The photocell works perfectly without resistor, but if you don’t want to overcharge it, then you should use a 10KOhm resistor and connect it between the analog input and the 5V pin.

Finally you will have to connect the MIDI adapter, which goes connected to the TX0 pin, the ground pin and to the 5V pin. You will have to connect the adapter with two 220KOhm resistors. One of them will go to the TX0 pin and the other one to the 5V pin.

Step 9: Arduino Code

The original code was written by Evan Kale but it has been edited and modified by me. It contains some Spanish concepts, so if you have any questions please let me know.



Email: victorherrero16@gmail.com

See Evan Kale's original work:



Step 10: Structure and Other Things

If you want to build a homemade structure too, i recommend you to use PVC. However, you will save a lot of time and work if you get a second hand drum structure. This way you will only have to adapt your Pads to the hook of that structure.

About the connection to a computer/mobile device, you will have to buy a MIDI interface or a MIDI to USB cable. You can find them on amazon, aliexpress...

Circuits Contest 2016

Second Prize in the
Circuits Contest 2016

2 People Made This Project!


  • Clocks Contest

    Clocks Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Oil Contest

    Oil Contest

98 Discussions

Hi Victor! Which program did you use to link the drums sounds? I'm trying with FL Studio, but I don't know if there's another simpler.

1 more answer

Hi there! I used EzDrummer 2, pretty basic but more than enough...


Question 27 days ago

Hitting a bit of a head scratcher while putting together a slightly modified version of this.

I have adjusted the code for only three pads.

When my Arduino Mega 2560 is connected to PC and viewing in Serial Monitor I am receiving output when pads are being struck and only when pads are being struck.

When the Arduino is being powered by 12v power supply and MIDI plugged through USB to MIDI controller I am receiving only the following input (viewed in MIDI-Ox) spammed like crazy with no response to any pad strikes.

Status: 90

Data 1: 00

Data 2: 00

Channel: 1

Note: C -1

Event: Note Off

Checked all my connections and all seems in order, I do not receive crazy input from using the same MIDI to USB with other manufactured MIDI devices.

Code being used:

#define NUM_PIEZOS 3

#define CAJA_THRESHOLD 20 //anything < TRIGGER_THRESHOLD is treated as 0



//#define LCYM_THRESHOLD 100

//#define RCYM_THRESHOLD 100

//#define BTOM_THRESHOLD 20

//#define HIHAT_THRESHOLD 80

//#define BOMB_THRESHOLD 20


#define CAJA_NOTA 38

#define LTOM_NOTA 48

#define RTOM_NOTA 47

//#define LCYM_NOTA 49

//#define RCYM_NOTA 51

//#define BTOM_NOTA 43

//#define HIHAT_NOTA 42

//#define BOMB_NOTA 36

//#define HIHAT2_NOTA 46

#define NOTA_ON_CMD 0x90 //The NOTE ON message is sent when the performer hits a key of the music keyboard. It contains parameters to specify the pitch of the note as well as the velocity (intensity of the note when it is hit).

#define NOTA_OFF_CMD 0x80 //When a synthesizer receives this message, it starts playing that note with the correct pitch and force level.When the NOTE OFF message is received, the corresponding note is switched off by the synthesizer.


#define VELOCIDAD_SERIAL 31250

#define SIGNAL_BUFFER_SIZE 100 //buffer=almacenar data temporal




//#define HIHAT_POS 0

int pinLDR = 9;

int Ledpin = 13;

int thresholdLDR = 350;

int valorLDR = 0;

unsigned short MapaAnalog[NUM_PIEZOS];

unsigned short MapaNotas[NUM_PIEZOS];

unsigned short MapaThreshold[NUM_PIEZOS];

//llama buffers para guardar señales analogicas y picos

short indexActualSignal[NUM_PIEZOS];

short indexActualPico[NUM_PIEZOS];

unsigned short BufferSignal[NUM_PIEZOS][SIGNAL_BUFFER_SIZE];

unsigned short BufferPico[NUM_PIEZOS][PEAK_BUFFER_SIZE];

boolean notaLista[NUM_PIEZOS];

unsigned short VelocidadNotaLista[NUM_PIEZOS];

boolean ultPicoCero[NUM_PIEZOS];

unsigned long ultTiempoPico[NUM_PIEZOS];

unsigned long ultTiempoNota[NUM_PIEZOS];

void setup()



//initialize globals

for(short i=0; i<NUM_PIEZOS; ++i)


indexActualSignal[i] = 0;

indexActualPico[i] = 0;



notaLista[i] = false;

VelocidadNotaLista[i] = 0;

ultPicoCero[i] = true;

ultTiempoPico[i] = 0;

ultTiempoNota[i] = 0;

MapaAnalog[i] = PRIMER_ANALOG + i;


MapaThreshold[0] = CAJA_THRESHOLD;

MapaThreshold[1] = RTOM_THRESHOLD;

MapaThreshold[2] = LTOM_THRESHOLD;

//MapaThreshold[3] = RCYM_THRESHOLD;

//MapaThreshold[4] = LCYM_THRESHOLD;

//MapaThreshold[5] = BTOM_THRESHOLD;

//MapaThreshold[6] = HIHAT_THRESHOLD;

//MapaThreshold[7] = BOMB_THRESHOLD;

MapaNotas[0] = CAJA_NOTA; //noteMap

MapaNotas[1] = RTOM_NOTA;

MapaNotas[2] = LTOM_NOTA;

//MapaNotas[3] = RCYM_NOTA;

//MapaNotas[4] = LCYM_NOTA;

//MapaNotas[5] = BTOM_NOTA;

//MapaNotas[6] = HIHAT_NOTA;

//MapaNotas[7] = BOMB_NOTA;

{//to check if it works -photocell

pinMode (pinLDR, INPUT);

pinMode (Ledpin, OUTPUT);



void loop()


unsigned long TiempoActual = millis();

for(short i=0; i<NUM_PIEZOS; ++i)


//get a new signal from analog read

unsigned short nuevaSignal = analogRead(MapaAnalog[i]);

BufferSignal[i][indexActualSignal[i]] = nuevaSignal;

//if new signal is 0

if(nuevaSignal < MapaThreshold[i])


if(!ultPicoCero[i] && (TiempoActual - ultTiempoPico[i]) > MAX_TIEMPO_ENTRE_PICOS)






//get previous signal

short indexSignalprevio = indexActualSignal[i]-1;

if(indexSignalprevio < 0) indexSignalprevio = SIGNAL_BUFFER_SIZE-1;

unsigned short Signalprevia = BufferSignal[i][indexSignalprevio];

unsigned short nuevoPico = 0;

//find the wave peak if previous signal was not 0 by going

//through previous signal values until another 0 is reached

while(Signalprevia >= MapaThreshold[i])


if(BufferSignal[i][indexSignalprevio] > nuevoPico)


nuevoPico = BufferSignal[i][indexSignalprevio];


//decrement previous signal index, and get previous signal


if(indexSignalprevio < 0) indexSignalprevio = SIGNAL_BUFFER_SIZE-1;

Signalprevia = BufferSignal[i][indexSignalprevio];


if(nuevoPico > 0)


grabanuevoPico(i, nuevoPico);





if(indexActualSignal[i] == SIGNAL_BUFFER_SIZE) indexActualSignal[i] = 0;


int input = analogRead(pinLDR);

if (input > thresholdLDR) {

digitalWrite(Ledpin, LOW);


else {

digitalWrite(Ledpin, HIGH);



void grabanuevoPico(short slot, short nuevoPico)


ultPicoCero[slot] = (nuevoPico == 0);

unsigned long TiempoActual = millis();

ultTiempoPico[slot] = TiempoActual;

//new peak recorded (newPeak)

BufferPico[slot][indexActualPico[slot]] = nuevoPico;

//1 of 3 cases can happen:

// 1) note ready - if new peak >= previous peak

// 2) note fire - if new peak < previous peak and previous peak was a note ready

// 3) no note - if new peak < previous peak and previous peak was NOT note ready

//get previous peak

short IndexPicoprevio = indexActualPico[slot]-1;

if(IndexPicoprevio < 0) IndexPicoprevio = PEAK_BUFFER_SIZE-1;

unsigned short Picoprevio = BufferPico[slot][IndexPicoprevio];

if(nuevoPico > Picoprevio && (TiempoActual - ultTiempoNota[slot]) > MIN_TIEMPO_ENTRE_PICOS)


notaLista[slot] = true;

if(nuevoPico > VelocidadNotaLista[slot])

VelocidadNotaLista[slot] = nuevoPico;


else if(nuevoPico < Picoprevio && notaLista[slot])


EnviaNota(MapaNotas[slot], VelocidadNotaLista[slot]);

notaLista[slot] = false;

VelocidadNotaLista[slot] = 0;

ultTiempoNota[slot] = TiempoActual;



if(indexActualPico[slot] == PEAK_BUFFER_SIZE) indexActualPico[slot] = 0;


void EnviaNota(unsigned short nota, unsigned short velocidad)


if(velocidad > MAX_MIDI_VELOCIDAD)


midiNotaOn(nota, velocidad);

midiNotaOff(nota, velocidad);


void midiNotaOn(byte nota, byte Velocidadmidi)


if (nota == 42 && analogRead(pinLDR) < thresholdLDR)













void midiNotaOff(byte nota, byte Velocidadmidi)






Anyone have any ideas as to where I may have made a wrong tun on this one?

Dear victorh88,

I happened to come across this project and it is amazing. I was wondering about the wiring diagram, in the diagram there are 5 piezos shown but there are 4 drum pads 3 cymbals and one foot pedalfor the kick drum would the rest go in A5,A7,and A8?

2 replies

Hey DoctorWho232,
The diagram is there only to understand how to connect the components! There are piezos missing as you are saying.
The piezos go, wherever you define them in the code!!!
In order to understand this check the code out and look where all the piezos are defined. I am telling you this because I dont remember if I had put the fotoresistor in A6

Hi, I tried to make a version of this using an arduino mega and 8 piezos. Hairlessmidi and FL studio 12. I tried replacing my arduino as well as the piezos and every component I used to make sure the hardware is fine but only the first six analog pins(A0-A5) are responding to signals from the piezos.

Here's the code I used (from @audreyobscura 's Arduino Xylophone instructable) :


//Adapted for an ArduinoMega

//from Jenna deBoisblanc and Spiekenzie Labs initial code


// User settable variables


int pinRead;

char pinAssignments[16] ={


byte PadNote[16] = {

57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72}; // MIDI notes from 0 to 127 (Mid C = 60)

int PadCutOff[16] =


400,400,200,800,400,400,400,400,400,400,400,400,400,400,400,400}; // Minimum Analog value to cause a drum hit

int MaxPlayTime[16] = {

90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90}; // Cycles before a 2nd hit is allowed

#define midichannel 1; // MIDI channel from 0 to 15 (+1 in "real world")

boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)


// Internal Use Variables


boolean activePad[16] = {

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Array of flags of pad currently playing

int PinPlayTime[16] = {

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Counter since pad started to play

byte status1;

int pin = 0;

int hitavg = 0;


// Setup


void setup()


Serial.begin(57600); // connect to the serial port 115200



// Main Program


void loop()


for(int pin=0; pin < 16; pin++) //


//int pin = 3;

// for (pinRead=0; pinRead < 16, pin++){

hitavg = analogRead(pinAssignments[pin]);


// read the input pin

if((hitavg > PadCutOff[pin]))


if((activePad[pin] == false))


if(VelocityFlag == true)


// hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)

hitavg = (hitavg / 8) -1 ; // Upper range




hitavg = 127;


MIDI_TX(144,PadNote[pin],hitavg); //note on

PinPlayTime[pin] = 0;

activePad[pin] = true;




PinPlayTime[pin] = PinPlayTime[pin] + 1;



else if((activePad[pin] == true))


PinPlayTime[pin] = PinPlayTime[pin] + 1;

if(PinPlayTime[pin] > MaxPlayTime[pin])


activePad[pin] = false;







// Transmit MIDI Message


void MIDI_TX(byte MESSAGE, byte PITCH, byte VELOCITY)


status1 = MESSAGE + midichannel;





Link to original project : https://www.instructables.com/id/Arduino-Xylophone/

I have also attached the circuit schematic if that may be needed.

Can anyone please help with this?


circuit diagram.jpg
1 more answer

One of the posible failures is the fact, that this guy used a code defining 16 notes and piezos. I would try to rewrite the code, defining only 8 of them (if that is what you are going to use). In any case, check wires again, they can always be a huge problem.
Hope I have been helpful!

Hi anyone can explain the place of resistor in piezo, is that the end of resistor is in red cable and in black cable in another end?

Sorry I never doing this electronic-kind of project before.


1 more answer

Hi, the resistor goes parallel to the piezo connection {one end of the resistor connected to the positive end of the piezo(usually red wire) and one to the ground(usually black wire)}.

hope it helps :)

In the picture, the blue lines indicate positive wire and black lines the ground

circuit diagram.jpg

Hi Victor,

first: GreatWork! Awesome!

But i have the same problem as many others posted:

When i hit a piezo, notes of other channels are also get fired.

You already commented this problem with the suggestion, that maybe cables are touching each other. But in my case i did the following try:

1. Set NUM_PIEZOS to 1, START_SLOT to 0, Plugged in one Piezo at Analog0 --> No Midi

2. Set NUM_PIEZOS to 2, START_SLOT to 0

Plugged in one Piezo to Analog0 and NO Piezo to Analog 1 --> Notes of both Slots are triggered.

Plugged in NO Piezo in Analog0 and one Piezo to Analog 1 --> same result.

Do you have further suggestions what could solve my problem?

Best regards from germany



7 months ago

will this code create a midi note off after a pad is hit, or will it be always on.

Hi Sir can i use this for my ipad garage band? because I have no drum software for my laptop. So I decided to use ipad instead of software. Thanks

2 replies

Yes you can, you just need a midi interface

Is this the same code and schematic?

Hi Victor, I'm experiencing two interesting scenarios and would deeply appreciate your advice:

1. HiHat Photocell cuts out all sound:

When the photocell threshold triggers the HiHat open note (46) it "cuts out" all sound (including the other piezos) after about 6 seconds of repeated triggering. This doesn't happen when it's on the Hihat closed note (42) so my assumption is that the photocell lets through too many volts, when it goes above the threshold, and saturates.

2. Multiple notes triggering on hard hits:

When hitting "hard", each piezo triggers the sound assigned to it plus the one that directly follows it on the note map. For example, A0 triggers both A0 and A1's notes and so does every other piezo in that same order. The piezos are not in contact with one another so it is not caused by vibration. I used Midi Loupe to see what is happening and it showed that two notes are being triggered at once.

Have you experienced any of these problems and do you have advice for fixing them? Thanks.

1 reply

I experienced both of the problems... The first one might be due to the resistance that the photocell has. Try to get another one, with a different resistance and check if that is what causes the problem.
The second one might be the circuit in itselve. Check out if there are any connectors touching eachother.

Hi guys, I am doing this amazing project and I was wondering what software did you used to actually produce sound? like what it's the program that you use for the drumkit to sound

Hi victorh88, I´m building your project, it is amaizing, I have a question tho, Could you tell me what was the software that you used to play the demo? I mean the MIDI software.


Same with 2 sounds of cymbal.. rim vs bell.