Go Down

Topic: MIDI library - not working on MEGA board? (Read 146 times) previous topic - next topic

Zeenek

Hi there,

I wrote the following code, which simply turns on LED when NoteOn event comes and turns it off, when NoteOff event comes. 

Code: [Select]
#include <MIDI.h>
 MIDI_CREATE_DEFAULT_INSTANCE();
 
void handleNoteOn(byte channel, byte pitch, byte velocity)
{
  digitalWrite(4, HIGH);
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{
  digitalWrite(4, LOW);
}

void setup()
{
pinMode(4, OUTPUT);
digitalWrite(4, HIGH); // blink once to check if wiring is correct
delay(500);
digitalWrite(4, LOW);

MIDI.setHandleNoteOn(handleNoteOn);
MIDI.setHandleNoteOff(handleNoteOff);
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(115200);
}

void loop()
{
    MIDI.read();
}


The problem is that it doesn't work on my MEGA2560 board. The LED blinks once after reset (as it stands in setup function), but it doesn't react for any MIDI data. I checked it on UNO R3 board and it worked perfectly.

Link to the library: https://github.com/FortySevenEffects/arduino_midi_library/

Go Up