Serial Port in Midi Library 3.1

Hi all

I am using Mega2560 and I would like to use Midi Library for PC to Arduino communication.

I would like to use the Serial1 (Pin 18,19) for doing it. but I can't find and reference or simple for change the Serial port in function.

from playground
http://www.arduino.cc/playground/Main/MIDILibrary

Compatible with all Arduino boards. Possibility to choose which serial port to use if more than one available.

Class function reference
http://arduinomidilib.sourceforge.net/a00001.html#ac34d163205bb01ac5e03df7e64facebe

I have been searching in forum but only find v2.5 is no support...

Thank you :slight_smile:

Apparently you are supposed to change this line in MIDI.h:

#define USE_SERIAL_PORT Serial

You also need to use the #20 version of the Arduino IDE. Above versions do not compile well the Midi library. Otherwise you'll get errors like this one when compiling.

ERROR : 'Serial' was not declared in this scope

Also, you may want to update the code and replace the call for

Midi midi(Serial);

by

Midi midi(Serial[color=red]x[/color]);

where x stands for either 1 or 2, considering the Mega UARTS.