Website and Forum
MIDI Library help
Topic: MIDI Library help
(Read 1 time)
MIDI Library help
Mar 05, 2014, 02:21 am
I'm having trouble using the MIDI Library. Specifically the callback functions.
I downloaded this library and installed it. Im trying to start from the example MIDI_Callbacks. In order to see if the library is working, I'm simply trying to turn the pin 13 LED on and off on my Arduino UNO. A midi note on would turn the LED on and a note off turns it off. The only thing I've added to the example is a digitalWrite(led, HIGH) and a digitalWrite(led, LOW).
I'm using Hairless MIDI to serial bridge. I can see the note on and off is getting to the arduino UNO. the RX light lights up, but nothing ever lights up the pin13 LED.
I assume I'm missing something simple. I'm new to this. The code is below. Any help would be greatly appreciated!
int led = 13;
// This function will be automatically called when a NoteOn is received.
// It must be a void-returning function with the correct parameters,
// see documentation here:
void HandleNoteOn(byte channel, byte pitch, byte velocity)
// Do whatever you want when you receive a Note On.
if (velocity == 0)
// This acts like a NoteOff.
// Try to keep your callbacks short (no delays ect)
// otherwise it would slow down the loop() and have a bad impact
// on real-time performance.
// Initiate MIDI communications, listen to all channels
// Connect the HandleNoteOn function to the library,
// so it is called upon reception of a NoteOn.
MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function
// Call MIDI.read the fastest you can for real-time performance.
// There is no need to check if there are messages incoming
// if they are bound to a Callback function.
// The attached method will be called automatically
// when the corresponding message has been received.