A while ago I built a MIDI foot controller to trigger samples from my mac (in Mainstage) while playing the keyboard, it was pretty easy and worked flawlessly.
The app that i was using to send the MIDI messages to the mac (hairless midi serial) is not working in the most recent versions of macOS, so i thought to add a MIDI OUT port to the controller and send the MIDI messages to the mac through a USB to MIDI interface like this one:
but it doesn't work, the mac receives some MIDI messages but not the ones it's supposed to, instead of receiving note on messages it's receiving reset messages and program messages with random values.
here's a sample of the messages i receive:

here's the code:
#include <MIDI.h>
// Button 1:
int button = 2;
int buttonState;
int prevButtonState = 1;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
//Button2:
int button2 = 3;
int buttonState2;
int prevButtonState2 = 1;
unsigned long lastDebounceTime2 = 0;
unsigned long debounceDelay2 = 50;
//Button3:
int button3 = 4;
int buttonState3;
int prevButtonState3 = 1;
unsigned long lastDebounceTime3 = 0;
unsigned long debounceDelay3 = 50;
//Button4:
int button4 = 5;
int buttonState4;
int prevButtonState4 = 1;
unsigned long lastDebounceTime4 = 0;
unsigned long debounceDelay4 = 50;
//Button5:
int button5 = 6;
int buttonState5;
int prevButtonState5 = 1;
unsigned long lastDebounceTime5 = 0;
unsigned long debounceDelay5 = 50;
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
//Global
MIDI.begin(MIDI_CHANNEL_OFF);
//Button1
pinMode(button, INPUT_PULLUP);
//Button2
pinMode(button2, INPUT_PULLUP);
//Button3
pinMode(button3, INPUT_PULLUP);
//Button4
pinMode(button4, INPUT_PULLUP);
//Button5
pinMode(button5, INPUT_PULLUP);
}
void loop() {
//Button1
int reading = digitalRead(button);
if (reading != prevButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == 0) {
MIDI.sendNoteOn(36, 127, 1);
delay(200);
MIDI.sendNoteOn(36, 0, 1);
}
}
}
prevButtonState = reading;
//Button2
int reading2 = digitalRead(button2);
if (reading2 != prevButtonState2) {
lastDebounceTime2 = millis();
}
if ((millis() - lastDebounceTime2) > debounceDelay2) {
if (reading2 != buttonState2) {
buttonState2 = reading2;
if (buttonState2 == 0) {
MIDI.sendNoteOn(38, 127, 1);
delay(200);
MIDI.sendNoteOn(38, 0, 1);
}
}
}
prevButtonState2 = reading2;
//Button3
int reading3 = digitalRead(button3);
if (reading3 != prevButtonState3) {
lastDebounceTime3 = millis();
}
if ((millis() - lastDebounceTime3) > debounceDelay3) {
if (reading3 != buttonState3) {
buttonState3 = reading3;
if (buttonState3 == 0) {
MIDI.sendNoteOn(40, 127, 1);
delay(200);
MIDI.sendNoteOn(40, 0, 1);
}
}
}
prevButtonState3 = reading3;
//Button4
int reading4 = digitalRead(button4);
if (reading4 != prevButtonState4) {
lastDebounceTime4 = millis();
}
if ((millis() - lastDebounceTime4) > debounceDelay4) {
if (reading4 != buttonState4) {
buttonState4 = reading4;
if (buttonState4 == 0) {
MIDI.sendNoteOn(42, 127, 1);
delay(200);
MIDI.sendNoteOn(42, 0, 1);
}
}
}
prevButtonState4 = reading4;
//Button5
int reading5 = digitalRead(button5);
if (reading5 != prevButtonState5) {
lastDebounceTime5 = millis();
}
if ((millis() - lastDebounceTime5) > debounceDelay5) {
if (reading5 != buttonState5) {
buttonState5 = reading5;
if (buttonState5 == 0) {
MIDI.sendNoteOn(44, 127, 1);
delay(200);
MIDI.sendNoteOn(44, 0, 1);
}
}
}
prevButtonState5 = reading5;
}</>
as you see, i'm only using MIDI OUT messages in the code.
For the MIDI OUT port i followed the diagram from this site:
https://learn.sparkfun.com/tutorials/midi-tutorial/hardware--electronic-implementation
at the bottom is the MIDI OUT port diagram.
Does anyone have any idea why is not working correctly?, the code is exactly the same that i used with hairless midi serial (i only removed a Serial.begin() in the setup function).