Arduino rullstol trumset (3 / 3 steg)
Steg 3: programvara
Lägg till Arduino_MIDI_Library_v4.2 och Bounce2-master bibliotek till din Arduino programmering ansökan.
https://github.com/FortySevenEffects/arduino_midi _...
https://github.com/thomasfredericks/Bounce2
Kopiera och klistra in följande i en arduino skiss och ladda ner det till din arduino.
Du kan behöva leka med MIDI-not nummer beroende på vilken enhet du använder bearbeta dem.
#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.
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
Bounce debouncer3 = Bounce();
Bounce debouncer4 = Bounce();
Bounce debouncer5 = Bounce();
Bounce debouncer6 = 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();
om (debouncer1.rose ()) {
MIDI.sendNoteOn (38, 120, 1);
Delay(10);
MIDI.sendNoteOff(38,0,1);
}
om (debouncer2.rose ()) {
MIDI.sendNoteOn (36, 120, 1);
Delay(10);
MIDI.sendNoteOff(36,0,1);
}
om (debouncer3.rose ()) {
MIDI.sendNoteOn (48, 120, 1);
Delay(10);
MIDI.sendNoteOff(48,0,1);
}
om (debouncer4.rose ()) {
MIDI.sendNoteOn (45, 120, 1);
Delay(10);
MIDI.sendNoteOff(45,0,1);
}
om (debouncer5.rose ()) {
MIDI.sendNoteOn (43, 120, 1);
Delay(10);
MIDI.sendNoteOff(43,0,1);
}
om (debouncer6.rose ()) {
MIDI.sendNoteOn (49, 120, 1);
Delay(10);
MIDI.sendNoteOff(49,0,1);
}
}