FortySevenEffects / arduino_midi_library

MIDI for Arduino
MIT License
1.56k stars 252 forks source link

MIDI Library with Arduino Uno WiFi Rev2 not working #287

Closed labamichnetvoll closed 2 years ago

labamichnetvoll commented 2 years ago

I tried to use the Arduino Uno WiFi Rev2 with this MIDI lIbrary and I dont get it to run.

Its a very simple Output Code:

`#include

define LED LED_BUILTIN

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() { pinMode(LED, OUTPUT); MIDI.begin(MIDI_CHANNEL_OFF); } void loop() { digitalWrite(LED, HIGH); MIDI.sendNoteOn(60, 127, 1); delay(1000);
MIDI.sendNoteOff(60, 0, 1); digitalWrite(LED, LOW); delay(1000); }`

The same code on the normal Arduino Uno runs fine, so the issue isn't on my hardware. It looks like the problem comes from the Arduino Uno WiFi Rev2. Any suggestions for me?

Thanks in advance

lathoub commented 2 years ago

What does not run? No led blinking? Or not receiving MIDI on the other side? (Not sure if the MIDI_CHANNEL_OFF inhibits sending notes)

labamichnetvoll commented 2 years ago

On a normal arduino uno this code works fine. So I don’t think it’s a software problem except for maybe another instance of the midi lib.

franky47 commented 2 years ago

What is it you expect it to do exactly?

Theoretically, this sketch should:

If you're looking into doing more advanced MIDI routing (like BLE or over IP/WiFi), you'll need to look into Transports.

labamichnetvoll commented 2 years ago

Yes. There I agree with your explanation of the theoretical result.

In Reality: The led is blinking fine but no MIDI Messages receive my computer at the program “Pocket MIDI”. I’ve tried the exact same code on an other arduino uno board (not the WiFi Rev2) and there with the same configuration and setup and hardware the code works fine. So blinking of the led and sending a MIDI Message every second.

but for some reason the uno wifi rev2 has some problems with this code.

labamichnetvoll commented 2 years ago

I've found the issue:

The Arduino Uno WiFi Rev2 has his first Hardwareserial called "Serial" only connected to the USB Port. The HardwarePins TX and RX are connected to "Serial1", so it not possible with this arduino to call the MIDI_CREATE_DEFAULT_INSTANCE function. instead you have to use MIDI_CREATE_INSTANCE(HardwareSerial,Serial1,MIDI);

https://www.arduino.cc/reference/en/language/functions/communication/serial/ http://fortyseveneffects.github.io/arduino_midi_library/a00023.html#a83fed545a39b0bd6e50adf2b85e89fb1

franky47 commented 2 years ago

Thanks for the feedback.

We have a way to detect the default hardware serial port name, it might need an update to be compatible with the Uno WiFi Rev2.