Introduction: Randomized Arduino Drum Machine
I like drum machines. However they are not always the easiest to build. I wanted one that is:
A. Simple, Yet Powerful - If it uses lots of components then it is too complicated
B. Sound - It's not much of a drum machine if it "beeps"
C. Easily Modifiable - If I can't change stuff for improvement, then it is kind of annoying.
A meticulous internet search wasn't so successful.
Finally, I found this but, even that was a bit un-editable although it was cool. I thought that the samples were a bit small and I for one was not going to rewrite a bunch of samples.
Therefore, I decided to play around with the code and rewrote my own version of it and tweaked it around until I got a sound I liked.
Remember: Make sure you have the Potentiometer on Analog Pin 1 and not Analog Pin Zero. The True Random library uses this wobbly voltage to pick random numbers.
I drew up a schematic from the code and then made it real.
I know this uses the TX (Digital Pin 1) and RX (Digital Pin Zero) but I had already built a Digital to Analog Converter shield for those pins and decided not to build it again.
Step 1: Parts and Stuff.
8 2K Resistors
1 Potentiometer
1 3-Pin Terminal Block
Male Headers
Arduino Uno
Perf Board/Breadboard
Step 2: Program.
#include <TrueRandom.h> /* You will need the TrueRandom library: http://code.google.com/p/tinkerit/wiki/TrueRandom Drum Machine mkII Original Code by: Sebastian Tomczak Remade to have random beats by: Blinkyblinky Have Fun! */ int wavesound; int delayval; int barLength = 16; byte kick[] = { 127, 80, 42, 5, 165, 242, 241, 233, 128, 73, 48, 22, 127, 69, 55, 113, 151, 183, 209, 217, 223, 228, 233, 215, 161, 117, 91, 76, 65, 49, 37, 31, 31, 48, 83, 120, 146, 166, 183, 198, 206, 210, 209, 199, 178, 145, 111, 88, 78, 73, 69, 67, 72, 80, 88, 97, 109, 124, 137, 150, 163, 171, 174, 172, 168, 160, 144, 125, 114, 110, 108, 104, 104, 106, 109, 110, 112, 117, 124, 129, 135, 142, 145, 145, 143, 140, 137, 132, 128, 125, 122, 119, 118, 119, 119, 119, 118, 118, 120, 124, 126, 129, 132, 135, 137, 137, 135, 132, 131, 130, 129, 128, 126, 126, 124, 123, 121, 120, 120, 122, 123, 124, 126, 128, 129, 130, 130, 131, 131, 131, 130, 130, 130, 129, 129, 128, 126, 125, 125, 124, 124, 124, 124, 125, 126, 126, 128, 128, 128, 129, 129, 129, 129, 129, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 127, 126, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126 }; byte snare[] = { 127, 215, 65, 212, 56, 102, 135, 122, 51, 201, 220, 46, 175, 80, 152, 95, 123, 116, 184, 155, 59, 122, 100, 161, 143, 173, 101, 155, 97, 73, 112, 98, 176, 96, 140, 77, 134, 109, 132, 149, 112, 149, 97, 161, 98, 151, 98, 155, 149, 112, 157, 103, 133, 106, 167, 97, 166, 108, 129, 124, 136, 146, 124, 136, 129, 150, 94, 130, 105, 141, 146, 128, 129, 99, 150, 121, 141, 99, 142, 116, 131, 114, 118, 143, 127, 143, 115, 144, 120, 137, 109, 129, 131, 139, 129, 113, 144, 119, 145, 117, 135, 129, 134, 136, 124, 130, 130, 139, 121, 136, 121, 132, 128, 127, 126, 122, 130, 126, 138, 120, 136, 122, 131, 123, 130, 128, 127, 128, 118, 132, 125, 131, 122, 131, 125, 131, 122, 126, 128, 126, 129, 121, 129, 123, 132, 129, 127, 131, 123, 128, 125, 130, 123, 131, 123, 128, 131, 129, 128, 126, 125, 124, 131, 121, 124, 129, 130, 126, 124, 126, 127, 130, 125, 126, 128, 126, 128, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 126, 128, 126, 127, 126, 128, 125, 127, 128, 128, 126, 126, 128, 126, 126, 128, 128, 128, 128, 128, 126, 128, 126, 126, 128, 128, 126, 126, 128, 128, 126, 126, 127, 126, 128, 126, 126, 128, 128, 128, 126, 126, 126, 128, 128, 126, 126, 126, 128, 128, 126, 128, 128, 126, 126 }; byte hat[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; byte crash[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; void setup() { // declare which of the DAC's pins are outputs DDRD = DDRD | B11111001; } void loop() { wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); wavesound = TrueRandom.random(1,6); playBeat(wavesound); } void playBeat(byte beat) { if(beat == 1) { for(int i = 0; i < 256; i ++) { delayMicroseconds(analogRead(1) + 1); } } else if(beat == 2) { playKick(); } else if(beat == 3) { playSnare(); } else if(beat == 4) { playHat(); } else if(beat == 5) { playCrash(); } delay(80); } void playKick() { for(int i = 0; i < 256; i ++) { PORTD = kick[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playSnare() { for(int i = 0; i < 256; i ++) { PORTD = snare[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playHat() { for(int i = 0; i < 256; i ++) { PORTD = hat[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playCrash() { for(int i = 0; i < 256; i ++) { PORTD = crash[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; }
Here is some more code you can try:
#include <TrueRandom.h> /* You will need the TrueRandom library: http://code.google.com/p/tinkerit/wiki/TrueRandom Drum Machine mkII Original Code by: Sebastian Tomczak Remade to have random beats by: Blinkyblinky Have Fun! */ int wavesound; int wavesound1; int wavesound2; int wavesound3; int wavesound4; int wavesound5; int wavesound6; int wavesound7; int wavesound8; int wavesound9; int wavesound10; int wavesound11; int wavesound12; int wavesound13; int wavesound14; int wavesound15; int wavesound16; int wavesound17; int wavesound18; int wavesound19; int wavesound20; int delayval; int barLength = 16; byte kick[] = { 127, 80, 42, 5, 165, 242, 241, 233, 128, 73, 48, 22, 127, 69, 55, 113, 151, 183, 209, 217, 223, 228, 233, 215, 161, 117, 91, 76, 65, 49, 37, 31, 31, 48, 83, 120, 146, 166, 183, 198, 206, 210, 209, 199, 178, 145, 111, 88, 78, 73, 69, 67, 72, 80, 88, 97, 109, 124, 137, 150, 163, 171, 174, 172, 168, 160, 144, 125, 114, 110, 108, 104, 104, 106, 109, 110, 112, 117, 124, 129, 135, 142, 145, 145, 143, 140, 137, 132, 128, 125, 122, 119, 118, 119, 119, 119, 118, 118, 120, 124, 126, 129, 132, 135, 137, 137, 135, 132, 131, 130, 129, 128, 126, 126, 124, 123, 121, 120, 120, 122, 123, 124, 126, 128, 129, 130, 130, 131, 131, 131, 130, 130, 130, 129, 129, 128, 126, 125, 125, 124, 124, 124, 124, 125, 126, 126, 128, 128, 128, 129, 129, 129, 129, 129, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 127, 126, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126 }; byte snare[] = { 127, 215, 65, 212, 56, 102, 135, 122, 51, 201, 220, 46, 175, 80, 152, 95, 123, 116, 184, 155, 59, 122, 100, 161, 143, 173, 101, 155, 97, 73, 112, 98, 176, 96, 140, 77, 134, 109, 132, 149, 112, 149, 97, 161, 98, 151, 98, 155, 149, 112, 157, 103, 133, 106, 167, 97, 166, 108, 129, 124, 136, 146, 124, 136, 129, 150, 94, 130, 105, 141, 146, 128, 129, 99, 150, 121, 141, 99, 142, 116, 131, 114, 118, 143, 127, 143, 115, 144, 120, 137, 109, 129, 131, 139, 129, 113, 144, 119, 145, 117, 135, 129, 134, 136, 124, 130, 130, 139, 121, 136, 121, 132, 128, 127, 126, 122, 130, 126, 138, 120, 136, 122, 131, 123, 130, 128, 127, 128, 118, 132, 125, 131, 122, 131, 125, 131, 122, 126, 128, 126, 129, 121, 129, 123, 132, 129, 127, 131, 123, 128, 125, 130, 123, 131, 123, 128, 131, 129, 128, 126, 125, 124, 131, 121, 124, 129, 130, 126, 124, 126, 127, 130, 125, 126, 128, 126, 128, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 125, 128, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, 126, 128, 126, 127, 126, 128, 125, 127, 128, 128, 126, 126, 128, 126, 126, 128, 128, 128, 128, 128, 126, 128, 126, 126, 128, 128, 126, 126, 128, 128, 126, 126, 127, 126, 128, 126, 126, 128, 128, 128, 126, 126, 126, 128, 128, 126, 126, 126, 128, 128, 126, 128, 128, 126, 126 }; byte hat[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; byte crash[] = { 127, 128, 225, 217, 99, 38, 61, 153, 152, 144, 133, 73, 122, 144, 65, 188, 87, 170, 164, 111, 122, 151, 114, 88, 174, 77, 140, 92, 122, 141, 156, 124, 121, 123, 126, 133, 132, 139, 119, 120, 127, 141, 130, 122, 129, 127, 132, 121, 139, 118, 130, 131, 129, 132, 130, 134, 126, 128, 130, 126, 122, 132, 129, 127, 131, 126, 128, 127, 126, 125, 127, 125, 128, 125, 128, 128, 127, 127, 126, 127, 128, 128, 128, 127, 127, 127, 127, 127, 128, 127, 127, 126, 127, 127, 128, 127, 128, 126, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 126, 126, 128, 127, 126, 127, 126, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 127, 127, 127, 126, 127, 127, 127, 126, 127, 127, 126, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 126, 126, 127, 126, 127, 126, 126, 126, 126, 126, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 126, 127, 127, 127, 126, 127, 126, 127, 127, 127, 127, 127, 126, 126, 127, 127, 126, 127, 127, 127, 127, 126, 127, 127, 127, 127, 127, 127, 127, 127 }; void setup() { // declare the SpeakerPin as an OUTPUT: DDRD = DDRD | B11111001; } void loop() { wavesound = TrueRandom.random(1,5); wavesound1 = TrueRandom.random(1,5); wavesound2 = TrueRandom.random(1,5); wavesound3 = TrueRandom.random(1,5); wavesound4 = TrueRandom.random(1,5); wavesound5 = TrueRandom.random(1,5); wavesound6 = TrueRandom.random(1,5); wavesound7 = TrueRandom.random(1,5); wavesound8 = TrueRandom.random(1,5); wavesound9 = TrueRandom.random(1,5); wavesound10 = TrueRandom.random(1,5); wavesound11 = TrueRandom.random(1,5); wavesound12 = TrueRandom.random(1,5); wavesound13 = TrueRandom.random(1,5); wavesound14 = TrueRandom.random(1,5); wavesound15 = TrueRandom.random(1,5); wavesound16 = TrueRandom.random(1,5); wavesound17 = TrueRandom.random(1,5); wavesound18 = TrueRandom.random(1,5); wavesound19 = TrueRandom.random(1,5); wavesound20 = TrueRandom.random(1,5); playBeat(wavesound); playBeat(wavesound1); playBeat(wavesound2); playBeat(wavesound3); playBeat(wavesound4); playBeat(wavesound5); playBeat(wavesound6); playBeat(wavesound7); playBeat(wavesound8); playBeat(wavesound9); playBeat(wavesound10); playBeat(wavesound11); playBeat(wavesound12); playBeat(wavesound13); playBeat(wavesound14); playBeat(wavesound15); playBeat(wavesound16); playBeat(wavesound17); playBeat(wavesound18); playBeat(wavesound19); playBeat(wavesound20); } void playBeat(byte beat) { if(beat == 1) { for(int i = 0; i < 256; i ++) { delayMicroseconds(analogRead(1) + 1); } } else if(beat == 2) { playKick(); } else if(beat == 3) { playSnare(); } else if(beat == 4) { playHat(); } else if(beat == 5) { playCrash(); } delay(80); } void playKick() { for(int i = 0; i < 256; i ++) { PORTD = kick[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playSnare() { for(int i = 0; i < 256; i ++) { PORTD = snare[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playHat() { for(int i = 0; i < 256; i ++) { PORTD = hat[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; } void playCrash() { for(int i = 0; i < 256; i ++) { PORTD = crash[i]; delayMicroseconds(analogRead(1) + 1); } PORTD = 127; }
Step 3: Okay...So What Exactly Is a DAC?
So How does it do it exactly?
Collin Cunningham will explain in more depth:
Step 4: Let's Get Started!
Build according to the schematic. I can supply pictures of my build in the end but my camera was broken at the time I made this and so, I don't have the pictures for during the build. Sorry.
Step 5: Let's Finish!
Solder the headers terminal and the output wires and commence testing. (make sure you screw in the potentiometer.)
Step 6: Done!
That's it!
If you need any help or you have any suggestions PM me or leave a comment below.

Participated in the
Arduino Challenge

Participated in the
Make It Real Challenge
14 Comments
Question 2 years ago on Step 5
Does this drum machine has midi sync option with an external midi device?
6 years ago
sir I am building this but unfortunately in your finished pic I can see another board in between ,now I am totally confused.where to do what.i have ardiuno board and drum kit board ,do I need anything more? Please email me or leave comment My email is sagar.ndl@gmail.com
6 years ago
Hi bro...! I'm new to Arduino!! Currently using uno...Im.doin a project on Arduino drums! I successfully built a midi drums.
.now try to upgrade to e drum..I fetched the audio samples into the Arduino Uno..
Used piezo sensor as input ..getting output thr 11
PCM library
(https://github.com/damellis/PCM/zipball/master)
When I hit one piezo i can able to hear the sound..but when I hit two piezo simultaneously..(.I.e kick and hats at same time )o I can't able to hear the both sound same time...struggling alot n this issue.I googled ,but n't able to find a solution...plz help me to fix the problem...
Fetching sample to Arduino
http://highlowtech.org/?p=1963
Code example;-
Void loop(){
If { piezo 1 > 100)
{
startPlayback( sample 1);
}
If { piezo 2> 100)
{
startPlayback( sample 2);
}
}
Reply 6 years ago
Like I said in my previous response, the problem is that the Arduino sequentially loops through the program waiting for a piezo hit, and when it detects one, it breaks the loop to play the sound that was hit. In that case, the Arduino is no longer checking for other hits, which is why two sounds can't be played simultaneously. I put some possible solutions in the reply to your last comment.
Reply 6 years ago
thnks for u reply...but its workin fine ..initially I have created MIDI drums...as a midi .. Arduino works fine...means it's checking simultaneous hits....
http://www.spikenzielabs.com/SpikenzieLabs/DrumKitKit.html
I guess the problm is on pcm...
help me...but I'm sure it s checking simultaneous piezo hits
6 years ago
Hi...I'm doin a project on Arduino drums..I added the drum kit samples in my uno..and played whenever piezo sensor reaches the maximum value..I.e
if ( piezo read > 80)
startPlayback();
for each sensor I assigned respective samples.
now the problm is.i m not able to play 2 samples simultaneously..means..wen I hit kick and hats same time...it doesn't workin...
I'm not using DAC ..playin digital signal directly ..used pcm library
please help soon as possible
Reply 6 years ago
Hello, doing two things at the same time on any processor is usually a problem, especially on microcontrollers like the Arduino. While I can't diagnose the exact problem without seeing the actual source code, I would imagine that the problem is that the Arduino sequentially loops through the program waiting for a piezo hit, and when it detects one, it breaks the loop to play the sound that was hit. In that case, the Arduino is no longer checking for other hits, which is why two sounds can't be played simultaneously. There are a few ways to fix this problem: although inefficient, a hardware solution would be to make each sound its own Arduino; a different solution would be to fiddle with the code to see if it can also check for double piezo hits. While I can help with the problem, I currently have limited access to a computer (on vacation for the next two weeks), so it might take a while before I can look in depth into any programming heavy problems.
10 years ago on Step 2
Why is hat and crash the same?
10 years ago on Introduction
I don`t understand what the Pot is for. What does it do?
Reply 10 years ago on Introduction
It is used for speed control. The drum sounds slow down/speed up as you turn the pot.
11 years ago on Introduction
Nice! What resistance is the pot?
Reply 11 years ago on Introduction
It can be any value you want...I used 1Megaohm but 10K, 5K 100K and most other values will work.
11 years ago on Introduction
Let's hear what it sounds like!
Reply 11 years ago on Introduction
I guess I was too lazy to shoot a video...Better get started...will get back soon.