Stap 2: programma.
#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; }
Hier is wat meer code die u kunt proberen:
#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; }