Created
February 1, 2022 02:28
-
-
Save kshoji/d272418dac139d0d8a54848ae907c9ca to your computer and use it in GitHub Desktop.
MIDI Send Tester for Arduino MIDI Shield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <MIDI.h> | |
// MIDI Library https://www.arduino.cc/reference/en/libraries/midi-library/ | |
// MIDI Shield https://www.sparkfun.com/products/12898 | |
// Usage: when LED D6 is ON, push D2 button. then 20 kind of MIDI data will send. | |
MIDI_CREATE_DEFAULT_INSTANCE(); | |
byte sysex[] = { 0x01, 0x02, 0x04, 0x08 }; | |
void setup() { | |
pinMode(6, OUTPUT); | |
pinMode(2, INPUT_PULLUP); | |
MIDI.begin(1); | |
// wait while button down | |
while (digitalRead(2) == HIGH); | |
// wait while button up | |
while (digitalRead(2) == LOW); | |
digitalWrite(6, HIGH); | |
for (int state = 0; state < 20; state++) { | |
switch (state) { | |
case 0: | |
MIDI.sendNoteOn(69, 127, 1); | |
break; | |
case 1: | |
MIDI.sendNoteOff(69, 0, 1); | |
break; | |
case 2: | |
MIDI.sendProgramChange(27, 1); | |
break; | |
case 3: | |
MIDI.sendControlChange(10, 61, 1); | |
break; | |
case 4: | |
MIDI.sendPitchBend(4095, 1); | |
break; | |
case 5: | |
MIDI.sendPolyPressure(69, 95, 1); | |
break; | |
case 6: | |
MIDI.sendAfterTouch(120, 1); | |
break; | |
case 7: | |
MIDI.sendAfterTouch(69, 121, 1); | |
break; | |
case 8: | |
MIDI.sendSysEx(4, (byte*)sysex); | |
break; | |
case 9: | |
MIDI.sendTimeCodeQuarterFrame(12); | |
break; | |
case 10: | |
MIDI.sendSongPosition(63); | |
break; | |
case 11: | |
MIDI.sendSongSelect(31); | |
break; | |
case 12: | |
MIDI.sendTuneRequest(); | |
break; | |
case 13: | |
MIDI.sendClock(); | |
break; | |
case 14: | |
MIDI.sendStart(); | |
break; | |
case 15: | |
MIDI.sendStop(); | |
break; | |
case 16: | |
MIDI.sendTick(); | |
break; | |
case 17: | |
MIDI.sendContinue(); | |
break; | |
case 18: | |
MIDI.sendActiveSensing(); | |
break; | |
case 19: | |
MIDI.sendSystemReset(); | |
break; | |
} | |
delay(200); | |
} | |
digitalWrite(6, LOW); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment