Created
January 18, 2019 22:20
-
-
Save knatten/74b307a030020fedbf9620083e03410a 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
#include "MIDIUSB.h" | |
void setup() { | |
pinMode(A1, OUTPUT); | |
pinMode(A2, OUTPUT); | |
} | |
int noteToPin(uint8_t note) { | |
if (note == 0x24) | |
return A1; | |
if (note == 0x25) | |
return A2; | |
} | |
void noteOn(uint8_t note) { digitalWrite(noteToPin(note), HIGH); } | |
void noteOff(uint8_t note) { digitalWrite(noteToPin(note), LOW); } | |
void loop() { | |
midiEventPacket_t rx = MidiUSB.read(); | |
if (rx.header != 0) { | |
if (rx.header == 0x09) { | |
noteOn(rx.byte2); | |
} | |
if (rx.header == 0x08) { | |
noteOff(rx.byte2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment