Anda di halaman 1dari 11

HOW TO MAKE AN ELECTRONIC DRUM.

(not a MIDI sampler) aka KIDU


by enjoyneer (http://www.instructables.com/id/ELECTRONIC-DRUMnot-a-MIDI-sampler-aka-KIDU/?ALLSTEPS)

This instructable is going to be about building an electronic drumset(not a MIDI sampler.),using an Arduino UNO R3., similar to a V-DRUM.It is code named KIDU. (Kompact Intelligent Drumming Unit).Some of the items used may be names differently in your locality.ill try to put as many pictures as posible. I saw many instructables based on arduino and MIDI outputs.i thought of making a completely independent instrument(ie with out a laptop). Advantages: (unlike V DRUM); * Very portable and easy to assemble. (the whole structure fits in a guitar case :-)) * The user can decide which sound each drum sounds like.One can even record a sound and upload it into the device and make that sound from a drum. (sound quality-16 MHz,16 bit mono) * You can use as much storage space for saving the sound files., depending on the size of the SD card you use. So a lot of sound styles can be included.For the sake of simplicity .,i used 5 styles of sound. * There is no base-drum. Instead the kick pedal contains a trigger.,that simulates a base kick. * Total cost just a fraction of what the original V DRUM will cost.I made it under 6000 rupees(~ $107). * There are no unnecessary buttons and knobs for selecting the drum styles. I have programmed it in such a way that., The drums themselves acts as the buttons.in this example.,i have used the snare drum to trigger the count,.and the tom1 drum as the select key. * There is no LCD display to guide you through selecting the drum style and the tones. but KIDU will narrate every step.,and what style you have selected. For example.,When KIDU startsup.,it asks you to enter the style count using the snare drum.Then you hit the snare drum with the drum stick less than 5 times,to select a drumming style,numbered from 1-5. General Advantages : (unlike acoustic drums) *KIDU can play a large number of percussion styles.,depending on the sounds that you have saved in it. *You can directly record the audio output.,on to any device that can record an audio signal,with out any ambient noise.for an acustic drum you may need a studio to record it ambient free. *You can practice it with out disturbing anyone.,by simply connecting a 3.3mm headphone jack into the output socket. *You can individually adjust the sensitivity of each of the drums through program or a control knob.FSOS(for the sake of simplicity)i have excluded the pots.I control their sensitivity by adjusting the threshold value in the program prior to upload.

Step 1: Stuff needed

*ELECTRONIC STUFF # Arduino UNO R3 # SD card shield # USB cable # 5 V adaptor # Micro SD card # Piezo electric transducer(aka piezo disk) # ribbon wire # single core shield wire. # Hook-up Wire. # Parallel PCB. # 2 contact jumpers. # 3.5mm audio jack (male n female) # Resistors- 1M & 10K (around 10 each) * HARDWARE STUFF # PVC PIPE(3.5cm and desired thickness) - 3 meters # PVC T-junctions elbows couplings stopper # Thermocoal(real thick). # Rubber like material(honestly dont kno its fancy name.:) any material which gives sum rigidity and bounce.i bounght it from a footwear manufacturing place.they use it for making the shoes soul. ) # Rexin(this material will be the artificial membrane.i used a black cloth like material.u can use anything to make it look cool.u can even use leather

.it wont affect the way your drum sounds.) # sumthing that looks cool..,to put your circuitary in.(i used an old laptop cooler-pad.lot f room inside n looks awesome.) * TOOLS NEEDED # Soldering equipments. # Cutting plier # Wire Stripper # Sissors (heavy duty thing) # Thermocol cutter # Hack saw # Measureing instrament. # Fevicol SR & SH(indian manufacturer for glue used for working with wood and footwear industry.u can use what ever is used for the same in your country :P ) # Insulation tape. # Ducttape or cello tape or masking tape. # sand paper(of variying grain size for metals.) # M-seal(a material that can be molded in to any size and sticks) # Spray paint.(Your choise.i used black.) * SOFTWARES NEEDED. # Arduino programming environment. # SOX (command line format converter) # FL Studio. * OTHER STUFF NEEDED. # A PC to program the Arduino. # An amplifier to Hear the sound

Step 2: WORKING

WORKING In this step,ill try to explain the working of our E DRUM (or KIDU as i call it) as simple as possible.Il just briefly talk about the steps for making each subsystem.,and then ill detail them in the following steps. Since we are working on an electronic drum.,the mechanical impulses(playin the drum).,needs to be coverted to electric signals.this task is done by the piezo discs. Each of the drums that we are make will contain 1 such piezo sensor. When ever a mechanical pressure is applied on the disks.,an electric signal whose magnitude is proportional to the pressure is produced. This signal is sent to the Arduinos analog pins(via pulldown resistors.,which i wil explain later) .Since there are only 6 anaog pins on an UNO.,the no of drums and cymbals used wil be restricted to 6. Step 3: MAKING THE FRAME

We use digital pins to trigger the base kick and the choke. The arduino is also linked to the SD Card shield.,with the SPI pins. (ie pins 13 to 10). Now the program.As you might already know.,the arduino's analog pins.,convert their analog inputs to a value between 0 and 1024.We program it such that if this value exeeds a particular thrush hold value.,then fetch the corresponding audio file from the sd card and play it through a PWM enabled pin.This is much easier said than done.There are some hurdles that we need to cross if we need to play an audio file from the SD card directly with out any audio decoder.(about which ill explain in detail later.) Another advantage of KIDU is that it does not require any control buttons. i have programmed it such that the drums themselves can be used to select the drumming style.

MAKING THE FRAME I am not very good at mechanical part of things..,but i tried my best. for making the drums and the structure or frame.,it used some materials (not the best materials i kno;)but i used them coz they are easy to work with and are very cheap and lightweight. But this step is pretty straight forward.Any one with little imagination can make.Jus follow the structural frame diagram. For making the frame of the KIDU.,i used PVC pipes with 3.5 cm diameter. ul need about 3 meters of it.We need to convert this 3 meter pvc into a structure as shown in the figure. I could just give you the exact mesurement of the frame components.but to tell u the truth.,i never had cut them to exact length.i just cut 1 meter pVC and checked if that is the length that i needed.wen i think its too much i measured and marked a little.i measured the height that i found comfortable to play.and i measured 4 such pillars.And found out the lengths of all the components by this trial and error method.but surprisingly nothing went to waste.Because all the components of the frame were small. and a lot of connections were there.so i used up almost 2.7 meter.very little was left over.This was the method i used(the fun way). But for those who dont like too much fun.,ill measure and mark the on another diagram. Step 4: MAKING THE DRUM

NAMING THE FRAME COMPONENTS. This is important because.,this is very helpful when we are assembling it together.It can be very confusing if we have alot of components and no way to kno which one is which.So i have made up a Structural frame assembly diagram.With each component a name. BL2 -BACK LEFT 2 BL1 -BACK LEFT 1 SL1 -SIDE LEFT 1 SL2 -SIDE LEFT 2 FL2 -FRONT LEFT 2 FL1 -FRONT LEFT 1 GL -GOINT LEFT ML -MIDDLE LEFT M -MIDDLE MR -MIDDLE RIGHT GR -GOINT RIGHT FR1 -FRONT RIGHT 1 FR2 -FRONT RIGHT 2 SR1 -SIDE RIGHT 1 SR2 -SIDE RIGHT 2 BR1 -BACK RIGHT 1 BR2 -BACK RIGHT 2 (i kno joint is spelled wrong.but i am jus gonna go with it :P ) Now connect the whole thing together,without the drums.and paint it using spray paint. TIPS :# name the components on the inside of the pipe and out side. in case it gets covered in paint. # while painting remember to keep the spray at atleast 25 cm from the workpice.contasntly move while spraying to get a fine finish. # keep the work piece in a newspaper to prevent paint from ruining anything else.

MAKING THE DRUM I am not very good at mechanical part of things..,but i tried my best. for making the drums and the structure or frame.,it used some materials (not the best materials i kno;)but i used them coz they are easy to work with and are very cheap and lightweight. As shown in the diagram.,the drum has 3 layers.Most of the drum is filled with Thermocol or foam.i used thermocol(better rigidity).I googed the drum sizes for a standard drum set.and cut 4 circles with these diameters on a large slab of thermocol.The drum sizes are listed below.Cut the rexin and boncy materials with the same diameters, as shown in the diagram. Now at the center of the thermocol cut a cylindrical grove such that the tail portion of the T junction fits tightly in the hole.Now mark 4 positions on the Thermocol nearby the portion of the t junction.(keep in mind that this is only for extra strengrth.the drums wudnt fall off even if the drummer drums it hard.). Now that you got an idea on were the t juction would be on the drum, remove the junction.Now using the sandpaper.,sand the sides of the thermocol .This is to getrid of any deformations that you may have while cutting. Make a grove on the thermocoal along the axis.(axis is the imaginary line on which the pvc pipe would lie on.) Now apply fevicol (SH grade) on the walls of the grove on the thermocoal and on the T junction.Do not use SR Grade coz it will melt the thermocol. (fevicol is the name of the manufacturer in india for glue.ill put up the picture also. u can use wat ever u have at your country.)And use a piece of string to tie the T junction and thermocol.,loop the

string throung the groves that we jus cut on the thermocol.now tie it hard tie on the T juncton.Apply the SR fevicol on the string were it touches the PVC T junction.(bevare not to tounch SR on the thermocol.)The SR would cause the PVC to melt parcialy and the thermocol gets fixed on the t junction. Now take a piezo disk and solder it with 2strand ribbon wire.(strip 2 from a 10 strand ribbon wire) make sure to insulate the both leads with insulation tape.now solder the other end of the wires to a female port 3.5mm audio jack.use a smal plastic piece to screw the jack in.Make sure that the length of the wire is equal to the radious of the drum.(we dont want any extra wire sticking out of the drum.) Using the SR glue.,glue the piezo disk on to the center of the boncy material that we cut out earlier.Use insulation tape to stick the wire a and the disk on to the circle.Now glue the side containing the piezo disk onto the thermocol.Make sure that the 3.5jack is properly placed.and can be pluged in from out side the drum.(Use only SH for sticking with thermocol.) Now use the SR glue to stick the rexin on to the boncy material.Leave for drying. Now for painting the drum.I used spray paint(paint-ina-can).The problem is that you cannot use this paint dirctly on thermocol.since it causes the same effect as the SR glue.it melts the whole thing. So make a coating of duct-tape on top of it before spraying it on. I also made a coating of news paper and then a coat of duct tape. (not necessary.) Apply a coat of paint.Hold the can a good 25 cm from the drum and spray it contantly moving,to get a good fine finish.or else.,it could be uneven.

Leave to dry.Repeat after 5 min. This step covers making of the drums.but making the cymbals and the pedals will be explained in another step.The problem is that i couldnt photograph the making of the cymbals and foot pedals.I don have them with me at the moment either.but ill take their photo as soon as i can and upload them too. Il up load the steps for now. Tips :# When ever you use a solvent(like fevicol SH or SR)u havnt worked with before.,always test it on a sample before applying it on the original. (i am emphasising this cos i wasted 1 of ma drums by using SR on thermocol.The whole thing melted into guie slimy slury :( ) # When u fix the jack (fixing the piezo) make sure that the jack would Step 5: Making the console

be on the easily plugable area of the drum.(u don want it to be on the left or right part of the drum.coz it may be difficuly wen another drum comes on its side.) # Always measure and mark the parameters on the drum by using sum permannt marker. # We would be cutting the matterial for all the 4 drums together. so its easy to mark them which drum they belong to.and their axis. # Always check how it would be on the frame before gluing on anything. note:- standard drum size as per a website i googled up. 18 x 22 inch bass drum 9 x 12 and 10 x 13 inch rack toms 16 x 16 inch floor tom 5.5 x 14 inch snare drum

MAKING THE CONSOLE. This is basicaly putting all the circuitary in a good looking box. and neatly puting together a way to establish an easily removable connection with the

drums. For the console i used an old usb powered laptopcoolerpad.I removed the fan from the pad and gluedon a small piece of cardboard.I connected the SD card

shield on to the arduino and screwed it on to the cardboard. Another important circuitary is the pulldown resistors. As explained earlier.,a piezo disk produces electric signal correspondin to the pressure applied on it.When we glued the drums together with the piezo inside.,it produces a signal even if we donot play the drum.So to over come this problem.,we put pull down resistors( 1M ~ 1.3M ) between the live and the ground leads of the piezo discs. we could put it with in the dums.but i decided to bring together all the pull down resistors needed onto a single pcb and put it in the console. This config makes it easier to do any maintenace if necessarty. The circuit diagram i very very simple. I connected 6 female jumper leads to a parallel PCB and used 6 resistors between each of the leads.Then i shorted 1 of the leads of all the jumper male pins using hook up wire.Then took the live lead out of each of the jumper pins and 1 of the shorted leads(for GND) and soldered each to 1 end of the ribbonwire.i connected small pieces of hookup wire to the end of ribbon wire(to make it easier for connecting to the Arduino). and connected these wires to the analog pins and the

ground.These pins were exposed to the exterior so that we could make the connections from outside. Next we connect the output audio socket(3.5mm female audio) on to the console. then we solder 2 strand ribbon wire to the ground and live of the socket and the other end to the hookup wire.(to make easy connection to the arduino.)Now make another hole on the console to take the piwer line out. I used the USB cable for programming the arduino for powering ther device. This way i can use the same line for powering the device and also for programming it.I connect the USB cable to a 5V USB adapter for powering. This also reduces the weight in the console due to heavy transformers for stepdown and more efficiency. Next the cable system.The cable system that i used was made of single core shield for best sound quality.Each of the drums,cymbals and the pedals will need a cable to be connected to the console.Cut approx 1.3 meters of shield wire.now solder 1 end of the shiel wire to the 3.5mm male jack. other end to the female part of the jumper wire.

Step 6: Preparing the sd card


PREPARING THE SD CARD. This was the most difficult and time consuming step for me.But ill upload all the the link for all the audio files that i have prepared.so that those who find it difficult to follow can use these files and skip this step. But i must warn you that ull miss a hell lot of fun :) . link is:
http://www.4shared.com/rar/AoDU14Vy/KIDU_files.html

Before we touch the sd card,we need to select the sounds that we want our drum to sound like.For this i used Image line FL studio for making each of the drum samples in wave format.For those who r not familier with Fl studio, you can simply google for drum samples and download them.If even that is too much.,ill upolad the link for the wav files that i have used as well :) . Once you have decided on the sounds that you want to hear.,lets start converting. As i told you in the WORKING.,it is not easy to play an audio format with out a dedicated audio decoder.If we had a WAV shield this would have been easier.Now for playing the audio file direcly from sd card.,we use the arduino library called the SimpleSDAudio.h . For this,library to function, we need the audio files in the .RAW format and the file name in 8.3 naming format,all present in the root directory of the SD card. For converting.,the wave files to raw.,i couldnt find any file converter softwares that support wav to raw.(total video converter also no good.) so i used a commmand line converter called SOX.You can

Audacity as GUI. but i used.,the commandline technique. First you need to install SOX.Now bring all the files that you need to convert to the same directory that contain the file SOX.exe . Now open command prompt and direct it to the same directory as SOX.exe (or create a notepad file in that directory and type command.com and save it as anything.bat.if u open this file the command prompt opens up with pointing to the same directory.).Now type in the following command. cd %~dp0 mkdir converted sox input.wav --norm=-1 -e unsigned-integer -b 8 -r 62500 -c 1 -t raw "converted\output.raw" pause replace input.wav in the above command with the filename that you are using. & output.raw with the 8.3 file name.(8.3 simpy means an 8 letter name or less,followed by a '.' & a format in 3 letters eg numb.mp3).So if you have selected the snare sound for conversion. type. cd %~dp0 mkdir converted sox snare.wav --norm=-1 -e unsigned-integer -b 8 -r 62500 -c 1 -t raw "converted\1_snr.raw" pause

As i have mentioned earlier there is no lcd display.All the selection of the style and other necessary things are also narrated by the KIDU.So all those audio files also need to be converted and transfered to the SD card. For these audio files also i used the speech synthesiser functionality of FL Studio.You can use any software and obtain the speech audio in wave format. and then convert to raw usin SOX.I will upload n link these audio files also. NAMING THE FILES. This is jus to make the programming a little easier.Be systematic in evrything you do. NOMENCLATURE FORMAT <stylecount>_<drumname>.raw names i have used : for style count 1 1_snr.raw 1_tom1.raw 1_tom2.raw 1_ft.raw 1_cy.raw

1_kick.raw 1_ohh.raw 1_chh.raw For stylecount 2 replace all the above first letter by 2.and so on for any number of styles. The speech files you can name anything. After you have all the files you need in the raw format.,we can transfer them to the SD card.For this you can use the windows in built formatter but i recommend the SD formatter.(do not do quick format.)For SD cards under 2GB format it as FAT.All others format with FAT32.The library supports both file systems. Now remove it safly from the PC and insert it inthe SD card shield. CAUTION:Your computer running on any OS (other than MSDOS) will not be able to play these RAW files.but not to worry it will play fine in the arduino.if u are not convinced of its genuinity.,u can convert these file back to wav or mp3 and play it in your computer.

Step 7: SOURCE CODE


; void setup() { Serial.begin(9600); SdPlay.setSDCSPin(10); // chip select SdPlay.init(SSDA_MODE_FULLR ATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER); Serial.println("sd ready"); SdPlay.setFile("startup.raw"); // plays the startup tone. SdPlay.play(); } void loop() { ////////////////////////////////// reading the analog pins snarecount=analogRead(snarepin); tom1choose=analogRead(tom1pin) tom2=analogRead(tom2pin); floortom=analogRead(floortompin); cymbal=analogRead(cymbalpin); highhat=analogRead(highhatpin); //////////////////////////////////drum style selection. if (snarecount>100)

// variables and constants used. int snare; int tom1; int tom2; int floortom; int cymbal; int highhat; int stylecount=0; int select=0; int snarecount; int tom1choose; ////////////////////// const int snarepin=A0; const int tom1pin=A1; const int tom2pin=A2; const int floortompin=A3; const int cymbalpin=A4; const int highhatpin=A5; #include <SimpleSDAudio.h>

{ SdPlay.setFile("slctdrm.raw"); // KIDU says "select the drumming stye!" SdPlay.play(); stylecount=stylecount+1; } if (stylecount>6) { stylecount=1; } ///////////////////////////////////////play name of drum style. if (stylecount==1) {

SdPlay.setFile("1_stdstl.raw"); // KIDU says "standard drum set selected!" SdPlay.play(); } if (stylecount==2) { SdPlay.setFile("2_afrcon.raw"); // KIDU says "african-congo style selected!" SdPlay.play(); } if (stylecount==3) { SdPlay.setFile("3_hiho.raw"); // KIDU says "hiphop style selected" SdPlay.play(); } if (stylecount==4) { SdPlay.setFile("4_indian.raw"); // KIDU says "indian style selected" SdPlay.play(); } if (stylecount==5) { SdPlay.setFile("5_funny.raw"); // KIDU says "funny sounds selected" SdPlay.play(); } if (stylecount==6) { SdPlay.setFile("6_demo.raw"); // plays DEMO. SdPlay.play(); }

Serial.println("select="); Serial.println(select); while (select==1) { ////////////////////////////////////redefning the variables to be drum sound triggers. snare=analogRead(snarepin); tom1=analogRead(tom1pin); tom2=analogRead(tom2pin); floortom=analogRead(floortompin); cymbal=analogRead(cymbalpin); highhat=analogRead(highhatpin);

if (snare>50 && stylecount==2) { SdPlay.setFile("2_snare.raw"); SdPlay.play(); Serial.println("2snare"); } if (tom1>50 && stylecount==2) { SdPlay.setFile("2_tom1.raw"); SdPlay.play(); Serial.println("2tom1"); } if (tom2>50 && stylecount ==2) { SdPlay.setFile("2_tom2.raw"); SdPlay.play(); Serial.println("2tom2"); } if (floortom>50 && stylecount==2) { SdPlay.setFile("2_ft.raw"); SdPlay.play(); Serial.println("2floortom"); } if (cymbal>50 && stylecount==2) { SdPlay.setFile("2_cy.raw"); SdPlay.play(); Serial.println("2cymbal"); } if (highhat>50 && stylecount==2) { SdPlay.setFile("2_ohh.raw"); SdPlay.play(); Serial.println("2open highhat"); } //////////////////////////////////////////////style3 if (snare>50 && stylecount==3) { SdPlay.setFile("3_snare.raw"); SdPlay.play(); Serial.println("3snare"); } if (tom1>50 && stylecount==3) { SdPlay.setFile("3_tom1.raw"); SdPlay.play(); Serial.println("3tom1"); } if (tom2>50 && stylecount ==3)

if (snare>50 && stylecount==1) { SdPlay.setFile("1_snare.raw"); SdPlay.play(); Serial.println("snare"); } if (tom1>50 && stylecount==1) { SdPlay.setFile("1_tom1.raw"); SdPlay.play(); Serial.println("tom1"); } if (tom2>50 && stylecount ==1) { SdPlay.setFile("1_tom2.raw"); SdPlay.play(); Serial.println("tom2"); } if (floortom>50 && stylecount==1) { SdPlay.setFile("1_ft.raw"); SdPlay.play(); Serial.println("floortom"); } if (cymbal>50 && stylecount==1) { SdPlay.setFile("1_cy.raw"); SdPlay.play(); Serial.println("cymbal"); } if (highhat>50 && stylecount==1) { SdPlay.setFile("1_ohh.raw"); SdPlay.play(); Serial.println("open highhat"); } //////////////////////////////////////////style 2

///////____________________count to exit the drums from select pin mode. if (tom1choose>50) { SdPlay.setFile("selected.raw"); SdPlay.play(); select=select+1; } Serial.println("stylecount="); Serial.println(stylecount);

{ SdPlay.setFile("3_tom2.raw"); SdPlay.play(); Serial.println("3tom2"); } if (floortom>50 && stylecount==3) { SdPlay.setFile("3_ft.raw"); SdPlay.play(); Serial.println("3floortom"); } if (cymbal>50 && stylecount==3) { SdPlay.setFile("3_cy.raw"); SdPlay.play(); Serial.println("3cymbal"); } if (highhat>50 && stylecount==3) { SdPlay.setFile("3_ohh.raw"); SdPlay.play(); Serial.println("3open highhat"); } /////////////////////////////////////////indian style if (snare>50 && stylecount==4) { SdPlay.setFile("4_snare.raw"); SdPlay.play(); Serial.println("4snare"); } if (tom1>50 && stylecount==4) { SdPlay.setFile("4_tom1.raw"); SdPlay.play(); Serial.println("4tom1");

} if (tom2>50 && stylecount ==4) { SdPlay.setFile("4_tom2.raw"); SdPlay.play(); Serial.println("4tom2"); } if (floortom>50 && stylecount==4) { SdPlay.setFile("4_ft.raw"); SdPlay.play(); Serial.println("4floortom"); } if (cymbal>50 && stylecount==4) { SdPlay.setFile("4_cy.raw"); SdPlay.play(); Serial.println("4cymbal"); } if (highhat>50 && stylecount==4) { SdPlay.setFile("4_ohh.raw"); SdPlay.play(); Serial.println("4open highhat"); } ////////////STYLE 5 FUNNY if (snare>50 && stylecount==5) { SdPlay.setFile("5_snare.raw"); SdPlay.play(); Serial.println("5snare"); } if (tom1>50 && stylecount==5) { SdPlay.setFile("5_tom1.raw"); SdPlay.play(); Serial.println("5tom1");

} if (tom2>50 && stylecount ==5) { SdPlay.setFile("5_tom2.raw"); SdPlay.play(); Serial.println("5tom2"); } if (floortom>50 && stylecount==5) { SdPlay.setFile("5_ft.raw"); SdPlay.play(); Serial.println("5floortom"); } if (cymbal>50 && stylecount==5) { SdPlay.setFile("5_cy.raw"); SdPlay.play(); Serial.println("5cymbal"); } if (highhat>50 && stylecount==5) { SdPlay.setFile("5_ohh.raw"); SdPlay.play(); Serial.println("5open highhat"); } if (stylecount==6) { SdPlay.setFile("demo.raw"); SdPlay.play(); } } }

Step 8: SOURCE CODE WORKING


SOURCE CODE WORKING The library that we use to play the audio from the sd card is SimpleSDAudio.h .,the details of which i have explained indetail in the stem preparing the SD card. Now in the sketch.,i have programmes only for 4 drums and a cymbal. since i have not expained how to make the foot pedals. i will try my maximum to upload it asap.But i have converted the sounds for everything(8 components per drum style.)ie for 4 drums,1cymbal, open highhat & closed high hat.and kick As mentioned earlier.,the program uses the drums for triggring aswell. This was a bit of a chalenge for me.but i made it in the end. You may notice in the source code that i have done the analog reading

twice., with 2 drums having diferent variable names each time. The first time.,we use the snare and tom1 drums for selecting the drum style. The snare drum is used as the style count.the count goes from 1 to 6 and repeats from 1 again.You can add as much styles as the size of the SD card you use.You just have to upload all the sounds you need.

There is another count to loop through the next set of analog readings. this is the select count.wen ever you have set the count with ypur snare drum,we confrm it by the tom1 drum.once the tom1 drum is hit., it would start a select count.When the select count is 1,(ie the first hit on the tom1 drum),the loop for drum triggering starts. The drum trigering loop is quite simple.If the analog reading exeeds a thushold KIDU will sound the corresponding sound.And the loop continious. eg :if analogread value > thrushold & if stylecount==1 then,play the audio file 1_snare.raw for snare drum. prog eg: if (snare>50 && stylecount==1) { SdPlay.setFile("1_snare.raw"); SdPlay.play(); Serial.println("snare"); }

Now for the program involving kick ahd high-hat,its not very hard. All we need to do is include part for digital reading a button. We need to use a simple mono pulse switch and a debouncing function,for the kick. The debouncing function is present in the examples for arduino programming environment.and for high hat.,the debouncing and switch parts are the same. The if loop will have an extra condition each for open anf closed. ie if (choke==HIGH && highat>thrushold && stylecount==1) { SdPlay.setFile("1_chh.raw"); SdPlay.play(); Serial.println("closed highhat"); } if (choke==LOW && highat>thrushold && stylecount==1) { SdPlay.setFile("1_ohh.raw"); SdPlay.play(); Serial.println("open highhat"); }

Anda mungkin juga menyukai