MIDI Library
Install the library from here.
This library documentation seems somewhat overwhelming and difficult to carry out simple tasks such as specifying a different UART TX port when we looked. If you only need to send simple Note On and Note Off commands then you can just use the UART instead if preferred.
MIDI Using Basic UART Functions
#define MIDI_OUT_CHANNEL 0x0 //0x0 to 0xF
//----- SETUP MIDI PORT -----
Serial.begin(31250, SERIAL_8N1);
//MIDI Note On
Serial1.write(0x90 + MIDI_OUT_CHANNEL);
Serial1.write(43); //Note Number (0 - 127)
Serial1.write(64); //Velocity (64 is default for no velocity info available)
delay(50);
//MIDI Note Off
Serial1.write(0x80 + MIDI_OUT_CHANNEL);
Serial1.write(43); //Note Number (0 - 127)
Serial1.write(0); //Velocity (64 is default for no velocity info available)
delay(500);
//MIDI All Notes Off (Can be handy during development and as a general power up command to send)
Serial1.write(0xB0 + MIDI_OUT_CHANNEL);
Serial1.write(0x7B);
Serial1.write(0x00);
