From: Jamie White Date: Sun, 9 Dec 2012 11:18:09 +0000 (+0000) Subject: Add Arduino drums and guitar X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=6232378fbffa5ebe726bfeb531ce0b158703b579;p=miniband.git Add Arduino drums and guitar --- diff --git a/arduino/drums.ino b/arduino/drums.ino new file mode 100644 index 0000000..4b3c18c --- /dev/null +++ b/arduino/drums.ino @@ -0,0 +1,32 @@ + +#define THRESHOLD 64 +#define PADNUM 4 +#define PINLIMIT 500 + +int val; +int pinDelay; +int pinDelays[4] = { 0, 0, 0, 0 }; + +void setup() { + Serial.begin(57600); +} + +void loop() { + for(int i = 0; i < PADNUM; i++) { + val = analogRead(i); + pinDelay = pinDelays[i]; + + if(val >= THRESHOLD && pinDelay < 1) { + Serial.print(i); + Serial.print(","); + Serial.print(val); + Serial.println(); + pinDelays[i] = PINLIMIT; + } + + if (pinDelay > 0) { + pinDelays[i] = pinDelay - 1; + } + } +} + diff --git a/arduino/guitar.ino b/arduino/guitar.ino new file mode 100644 index 0000000..874a163 --- /dev/null +++ b/arduino/guitar.ino @@ -0,0 +1,32 @@ + +#define THRESHOLD 16 +#define PADNUM 1 +#define PINLIMIT 5000 + +int val; +int pinDelay; +int pinDelays[4] = { 0, 0, 0, 0 }; + +void setup() { + Serial.begin(57600); +} + +void loop() { + for(int i = 0; i < PADNUM; i++) { + val = analogRead(i); + pinDelay = pinDelays[i]; + + if (val >= THRESHOLD && pinDelay < 1) { + Serial.print(i); + Serial.print(","); + Serial.print(val); + Serial.println(); + pinDelays[i] = PINLIMIT; + } + + if (pinDelay > 0) { + pinDelays[i] = pinDelay - 1; + } + } +} +