-
This is also posted on the Arduino forum here. #include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
// -----------------------------------------------------------------------------
// This example shows the old way of checking for input messages.
// It's simpler to use the callbacks now, check out the dedicated example.
#define LED 13 // LED pin on Arduino Uno
// -----------------------------------------------------------------------------
void BlinkLed(byte num) // Basic blink function
{
for (byte i=0;i<num;i++)
{
digitalWrite(LED,HIGH);
delay(50);
digitalWrite(LED,LOW);
delay(50);
}
}
// -----------------------------------------------------------------------------
void setup()
{
pinMode(LED, OUTPUT);
MIDI.begin(); // Launch MIDI, by default listening to channel 1.
}
void loop()
{
if (MIDI.read()) // Is there a MIDI message incoming ?
{
switch(MIDI.getType()) // Get the type of the message we caught
{
case midi::SystemExclusive: // If it is SysEx,
BlinkLed(5); // blink the LED 5 times
break;
// See the online reference for other message types
default:
break;
}
} If the microcontroller recognizes incoming SysEx data, it blinks the LED 5 times.
To decode the first few bytes: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It looks like a long message, by default the library handles SysEx up to 128 bytes. Any message longer than that may cause issues. Fortunately, you can increase the maximum SysEx size in the settings: struct MySettings : public midi::DefaultSettings
{
static const unsigned SysExMaxSize = 256; // Accept SysEx messages up to 256 bytes long.
};
// Create a 'MIDI' object using MySettings bound to Serial2.
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, MIDI, MySettings); |
Beta Was this translation helpful? Give feedback.
It looks like a long message, by default the library handles SysEx up to 128 bytes.
Any message longer than that may cause issues.
Fortunately, you can increase the maximum SysEx size in the settings: