Hi! Guys! I am using
Arduino Mega 2560 (it works with basic "blink" and other simple codes)
Midi library v.4.2
When i press keys on piano, the TX LED on arduino is blinking, what tells me, that it's recieve data, right?
But callbacks ( MIDI.setHandleNoteOn, MIDI.setHandleNoteOff) don't work.
If i press a lot of notes fast and randomly, sometimes LED 13 can switch on and off.
This is my circuit.
This is my code:
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
#define LED 13 // Arduino Board LED is on Pin 13
MIDI_CREATE_DEFAULT_INSTANCE();
// -----------------------------------------------------------------------------
void setup()
{
pinMode (LED, OUTPUT);
MIDI.setHandleNoteOn(non);
MIDI.setHandleNoteOff(noff);
MIDI.begin(1);
}
void loop()
{
MIDI.read();
}
void non (byte channel, byte pitch, byte velocity)
{
digitalWrite(LED,HIGH);
}
void noff(byte channel, byte pitch, byte velocity)
{
digitalWrite(LED,LOW);
}
Any suggestions?
Thanks for help!