Stap 3: Software
De Arduino_MIDI_Library_v4.2 en Bounce2-meester librarys toevoegen aan uw Arduino programmering van toepassing.
https://github.com/FortySevenEffects/arduino_midi _...
https://github.com/thomasfredericks/Bounce2
Kopieer en plak het volgende in een arduino schets en naar beneden laden aan uw arduino.
Het is wellicht om te rotzooien met de MIDI Opmerking nummers afhankelijk van het apparaat dat u gebruikt om ze te verwerken.
#include
#include
MIDI_CREATE_DEFAULT_INSTANCE();
Const int button_1 = 2;
Const int button_2 = 3;
Const int button_3 = 4;
Const int button_4 = 5;
Const int button_5 = 6;
Const int button_6 = 7;
Debouncer1 stuiteren = Bounce();
Debouncer2 stuiteren = Bounce();
Debouncer3 stuiteren = Bounce();
Debouncer4 stuiteren = Bounce();
Debouncer5 stuiteren = Bounce();
Debouncer6 stuiteren = Bounce();
VOID Setup {}
MIDI.begin(MIDI_CHANNEL_OMNI);
pinMode (button_1, INPUT_PULLUP);
pinMode (button_2, INPUT_PULLUP);
pinMode (button_3, INPUT_PULLUP);
pinMode (button_4, INPUT_PULLUP);
pinMode (button_5, INPUT_PULLUP);
pinMode (button_6, INPUT_PULLUP);
debouncer1.attach(Button_1);
debouncer1.interval(5);
debouncer2.attach(button_2);
debouncer2.interval(5);
debouncer3.attach(BUTTON_3);
debouncer3.interval(5);
debouncer4.attach(button_4);
debouncer4.interval(5);
debouncer5.attach(button_5);
debouncer5.interval(5);
debouncer6.attach(button_6);
debouncer6.interval(5);
}
void loop {}
debouncer1.update();
debouncer2.update();
debouncer3.update();
debouncer4.update();
debouncer5.update();
debouncer6.update();
Als (debouncer1.rose ()) {}
MIDI.sendNoteOn (38, 120, 1);
delay(10);
MIDI.sendNoteOff(38,0,1);
}
Als (debouncer2.rose ()) {}
MIDI.sendNoteOn (36, 120, 1);
delay(10);
MIDI.sendNoteOff(36,0,1);
}
Als (debouncer3.rose ()) {}
MIDI.sendNoteOn (48, 120, 1);
delay(10);
MIDI.sendNoteOff(48,0,1);
}
Als (debouncer4.rose ()) {}
MIDI.sendNoteOn (45, 120, 1);
delay(10);
MIDI.sendNoteOff(45,0,1);
}
Als (debouncer5.rose ()) {}
MIDI.sendNoteOn (43, 120, 1);
delay(10);
MIDI.sendNoteOff(43,0,1);
}
Als (debouncer6.rose ()) {}
MIDI.sendNoteOn (49, 120, 1);
delay(10);
MIDI.sendNoteOff(49,0,1);
}
}