Last active
February 6, 2024 22:08
-
-
Save lean8086/ec8da7486ec3621f9f0b90542a06fcea to your computer and use it in GitHub Desktop.
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
// Channel can be a number from 0 to 15. Typically displayed as 1 to 16. | |
byte channel = 0; | |
// ... | |
void setup() { | |
// ... | |
pinMode(18, INPUT_PULLUP); | |
pinMode(19, INPUT_PULLUP); | |
} | |
void loop() { | |
if (digitalRead(18) == LOW) { channel = 0 } | |
if (digitalRead(19) == LOW) { channel = 1 } | |
// ... | |
} | |
void noteOn(byte pitch) { | |
MidiUSB.sendMIDI({0x09, 0x90 | channel, pitch, 127}); | |
MidiUSB.flush(); | |
} | |
void noteOff(byte pitch) { | |
MidiUSB.sendMIDI({0x08, 0x80 | channel, pitch, 0}); | |
MidiUSB.flush(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment