If I could see your code I might be able to help you with what to add and where. But basically for the DIN MIDI connection use Serial1 instead of Serial. Connect the MIDI circuit to pins 19 and 18 instead of 0 and 1. You'll finfd information about the serial ports at Serial - Arduino Reference Follow the begin() link down the page for a simple example showing using the various serial ports on a Mega.
To clarify what I said in our private conversation, you can use two MIDI interfaces, one USBSerialMIDI_Interface to communicate over USB using the “Serial” object, and one HardwareSerialMIDI_Interface to output over DIN.
Then connect them both to Control Surface using a MIDI pipe, as shown in the [Dual-MIDI-Interface.ino[/tt] example:
#include <Control_Surface.h>
// Create two MIDI interfaces
USBSerialMIDI_Interface usbmidi {115200};
HardwareSerialMIDI_Interface dinmidi {Serial1, MIDI_BAUD};
// Create a MIDI pipe factory to connect the MIDI interfaces to Control Surface
BidirectionalMIDI_PipeFactory<2> pipes;
// Add some MIDI elements to show that the MIDI interfaces actually work
CCPotentiometer pot = {A0, MIDI_CC::General_Purpose_Controller_1};
NoteValueLED led = {LED_BUILTIN, 0x3C};
void setup() {
// Manually connect the MIDI interfaces to Control Surface
Control_Surface | pipes | usbmidi;
Control_Surface | pipes | dinmidi;
// Initialize Control Surface _after_ connecting the interfaces
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}