Go Down

Topic: MIDI on RX1 and TX1 for Arduino MEGA does not work (Read 106 times) previous topic - next topic

Razoumihine

Hi,

I'm trying to use RX1/TX1 serial port for midi in and out, without success.

Actually, all midi data goes on TX0/RX0 pin, which is already used by USB.

Here is a simple example, which works fine when MIDI circuit is connected to TX0/RX0, but nothing happens when connected to TX1/RX1.

Code: [Select]

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

static const unsigned ledPin = 13;      // LED pin on Arduino

void setup()
{
    pinMode(ledPin, OUTPUT);
    MIDI.begin();                      // Launch MIDI
}

void loop()
{
        MIDI.sendNoteOn(42, 127, 1);    // Send a Note (pitch 42, velo 127 on channel 1)
        delay(1000);             // Wait for a second
        MIDI.sendNoteOff(42, 0, 1);     // Stop the note
   
}



Is there function that set the Serial port to be used for MIDI? I tried including the following in the void setup() without success:

Code: [Select]

Serial1.begin();

Thanks for you help,


Lionel

Razoumihine

Finally solved:

Replaced:
MIDI_CREATE_DEFAULT_INSTANCE();
With:
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

Cheers,
Lionel

Go Up