Hello,
i flashed the ATMega8u2 on my Arduino with the HIDUINO_MIDI_SYSEX Firmware.
This seems to work.
When I send sysex Messages from PC to Arduino. Arduino gets it and sends a callback. Using MIDI Library.
But I can't turn off the callbacks.
Any Ideas what is wrong with my code?
#include <MIDI.h>
const int buttonPin = 2;
int buttonState = 0, oldstate = 0;
void SysEx(void)
{
byte data[6] = {0x7E, 0x10, 0x20, 0x30, 0x40, 0x50};
MIDI.sendSysEx(6, data, false);
}
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.disconnectCallbackFromType(SystemExclusive);
pinMode(buttonPin, INPUT);
}
void loop() {
if (MIDI.read()) {
switch(MIDI.getType()) {
case SystemExclusive:
SysEx();
break;
default:
break;
}
}
else
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && oldstate == LOW) {
MIDI.sendNoteOn(1, 1, 10);
oldstate = buttonState;
}
if (buttonState == LOW && oldstate == HIGH) {
MIDI.sendNoteOff(1, 1, 10);
oldstate = buttonState;
}
}
}
Tank you!