Skip to content

Instantly share code, notes, and snippets.

@mirisuzanne
Created May 3, 2022 21:05
Show Gist options
  • Save mirisuzanne/22b217ce170a8d9dca09164692c49ab4 to your computer and use it in GitHub Desktop.
Save mirisuzanne/22b217ce170a8d9dca09164692c49ab4 to your computer and use it in GitHub Desktop.
#include <MIDI.h>
const int BUTTON = 2;
int currentState = HIGH;
int newState = HIGH;
byte goArray[7] = {0xf0, 0x7f, 0x7f, 0x02, 0x01, 0x01, 0xf7}; // GO array
MIDI_CREATE_DEFAULT_INSTANCE();
// Setup: runs once at startup
void setup() {
pinMode(BUTTON, INPUT_PULLUP);
MIDI.begin(MIDI_CHANNEL_OFF);
}
// Loop: runs forever
void loop() {
newState = digitalRead(BUTTON);
// Only run if button state changes
if (currentState != newState) {
// Only run when button is first pressed (keydown)
// The PULLUP mode means the button is LOW when pressed
if (newState == LOW) {
// This is the part I'm not sure of
// Here we're sending a Note ON command, definitely not what we want
// I suspect this should be MIDI.sendSysEx()
MIDI.sendSysEx(7, goArray, true);
}
delay(50); // Delay a bit to debonce
}
currentState = newState;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment