#include MIDI_CREATE_DEFAULT_INSTANCE(); #define LED 13 #define PAD1 A2 #define PAD2 A3 #define PAD3 A4 #define PAD4 A5 int threshold = 50; byte note1 = 28; byte note2 = 29; byte note3 = 30; byte note4 = 31; int pad1hit = 0; int pad2hit = 0; int pad3hit = 0; int pad4hit = 0; void setup() { // put your setup code here, to run once: Serial.begin(115200); MIDI.begin(4); pinMode(LED, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if (analogRead(PAD1) >= threshold) { pad1hit = 1; //Serial.print("max = "); //Serial.print(analogRead(PAD1)); } if (pad1hit == 1 && analogRead(PAD1) <= (threshold - 10)){ int volume1 = analogRead(PAD1); digitalWrite(LED, HIGH); //Serial.print("Volume1 ="); //Serial.print(analogRead(PAD1)); MIDI.sendNoteOn(note1, volume1, 1); MIDI.sendNoteOff(note1, 0, 1); volume1=0; pad1hit = 0; } digitalWrite(LED, LOW); if (analogRead(PAD2) >= threshold) { pad2hit = 1; //Serial.print("max = "); //Serial.print(analogRead(PAD1)); } if (pad2hit == 1 && analogRead(PAD2) <= (threshold - 10)){ int volume2 = analogRead(PAD2); digitalWrite(LED, HIGH); //Serial.print("Volume1 ="); //Serial.print(analogRead(PAD1)); MIDI.sendNoteOn(note2, volume2, 1); MIDI.sendNoteOff(note2, 0, 1); volume2=0; pad2hit = 0; } digitalWrite(LED, LOW); if (analogRead(PAD3) >= threshold) { pad3hit = 1; //Serial.print("max = "); //Serial.print(analogRead(PAD1)); } if (pad3hit == 1 && analogRead(PAD3) <= (threshold - 10)){ int volume3 = analogRead(PAD3); digitalWrite(LED, HIGH); //Serial.print("Volume1 ="); //Serial.print(analogRead(PAD1)); MIDI.sendNoteOn(note3, volume3, 1); MIDI.sendNoteOff(note3, 0, 1); volume3=0; pad3hit = 0; } digitalWrite(LED, LOW); if (analogRead(PAD4) >= threshold) { pad4hit = 1; //Serial.print("max = "); //Serial.print(analogRead(PAD1)); } if (pad4hit == 1 && analogRead(PAD4) <= (threshold - 10)){ int volume4 = analogRead(PAD4); digitalWrite(LED, HIGH); //Serial.print("Volume1 ="); //Serial.print(analogRead(PAD1)); MIDI.sendNoteOn(note4, volume4, 1); MIDI.sendNoteOff(note4, 0, 1); volume4=0; pad4hit = 0; } digitalWrite(LED, LOW); }