# Arduino r4 midiusb

**URL:** <https://forum.arduino.cc/t/arduino-r4-midiusb/1163393>\
**Category:** Libraries\
**Created:** [August 29, 2023, 10:44pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393 "2023-08-29T22:44:59Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![RianDeRous](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@RianDeRous](https://forum.arduino.cc/u/RianDeRous)\
**Post date:** [August 29, 2023, 10:44pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/1 "2023-08-29T22:44:59Z")

</div>

Will the arduino uno r4 support the midiusb library? I get an error message that the Uno is not compatible, but on the Arduino website it says that the Uno is compatible with the MidiUSB library

> **[MIDIUSB - Arduino Reference](https://www.arduino.cc/reference/en/libraries/midiusb/)**
>
> The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [August 30, 2023, 3:49am UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/2 "2023-08-30T03:49:26Z")

</div>

Hi @RianDeRous

> [@RianDeRous](#):
>
> it says that the Uno is compatible with the MidiUSB library

Despite the similar names, the [**Uno**](https://docs.arduino.cc/hardware/uno-rev3) and [**UNO R4 Minima**](https://docs.arduino.cc/hardware/uno-r4-minima)/[**UNO R4 WiFi**](https://docs.arduino.cc/hardware/uno-r4-wifi) boards have significant differences in the context of library compatibility. You should not assume that a library will be compatible with the UNO R4 just because it indicates compatibility with the classic Uno board.

A word of advice when using the Arduino library reference, please keep in mind the "compatibility note" shown on the page:

> **Note:** while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.

If you read the documentation of the MIDIUSB library, you'll see that it is actually not compatible with the classic Arduino Uno board at all:

> microcontroller with native USB capabilities (atmega32u4 based boards or ARM boards)

In this respect, there is actually a better chance of eventual compatibility with the UNO R4 than the classic Arduino Uno, which does not have the native USB capability that is fundamental to this library.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [August 30, 2023, 4:09am UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/3 "2023-08-30T04:09:58Z")

</div>

You can check out what people have found compatable on the R4 on this page:-  
Compatibility Library list.

> **[GitHub - arduino/uno-r4-library-compatibility](https://github.com/arduino/uno-r4-library-compatibility)**
>
> Contribute to arduino/uno-r4-library-compatibility development by creating an account on GitHub.

> [@RianDeRous](#):
>
> but on the Arduino website it says that the Uno is compatible with the MidiUSB library

No it doesn't. It mentions the Uno and the Nano in the list of compatible devices but it adds the caveat.

> #### Compatibility Note
> 
> **Note:** while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.

The Uno and Nano do not have these features that will allow it to function.

---

<div class="post-metadata">

**Author:** ![RianDeRous](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@RianDeRous](https://forum.arduino.cc/u/RianDeRous)\
**Post date:** [August 30, 2023, 7:36am UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/4 "2023-08-30T07:36:22Z")

</div>

It is very misleading to put the Arduino Uno on that list, especially when you know that the R4 does indeed have the USB functionality. I bought an 'R4 minima' to try this - because it's advertised with it's USB functionality - and was disappointed to see that I need another board.

(Fortunately I have not yet sent my pcb design to be manufactured for this project)

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [August 30, 2023, 9:43pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/5 "2023-08-30T21:43:48Z")

</div>

> [@RianDeRous](#):
>
> and was disappointed to see that I need another board.

No I have been experimenting and you can do it with what you have, providing you install on your computer an app called 'hairless'. This takes the normal serial data coming into the computer and converts it to MIDI data.  
Then the simple #include \<MIDI.h\> will work. Here is a sketch I modified from the simple example. It sends one note in response to a MIDI read and another note along with a blinking LED at 2 second intervals if nothing is sent.

```arduino
#include <MIDI.h>

// Simple tutorial on how to receive and send MIDI messages.
// Here, when receiving any message on channel 4, the Arduino
// will blink a led and play back a note for 1 second.

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    MIDI.begin(4); // Launch MIDI and listen to channel 4
}

void loop()
{
    if (MIDI.read()) // If we have received a message
    {
        sendNote();
    }
    else{
      sendNote2();
    }
}

void sendNote(){
        //digitalWrite(LED_BUILTIN, HIGH);
        MIDI.sendNoteOn(61, 127, 1); // Send a Note (pitch 61, velo 127 on channel 1)
        delay(1000); // Wait for a second
        MIDI.sendNoteOff(61, 0, 1); // Stop the note
        //digitalWrite(LED_BUILTIN, LOW);

}

void sendNote2(){
        digitalWrite(LED_BUILTIN, HIGH);
        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
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);

}
```

I have tested this on both the R4 Minima and the R4 W-Fi. You need to set the baud rate on hairless to 115200 bauds.

here is a screen dump of this working with the Minima.

 ![Midi On R4](https://europe1.discourse-cdn.com/arduino/original/4X/e/1/f/e1fb57b41732b1296daa9f6c6f8a0c278463f948.jpeg)

on the left is hairless, and on the right is the same thing being picked up on Bus 1. All you need to do is to point your MIDI device towards this bus.

---

<div class="post-metadata">

**Author:** ![RianDeRous](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@RianDeRous](https://forum.arduino.cc/u/RianDeRous)\
**Post date:** [August 31, 2023, 7:33am UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/6 "2023-08-31T07:33:39Z")

</div>

Thank you! I didn't know such a program exists. I'll try this out. Thank you!

(and hope they'll adapt the midusb library to use the R4's USB functionality in the near future)

---

<div class="post-metadata">

**Author:** ![RianDeRous](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@RianDeRous](https://forum.arduino.cc/u/RianDeRous)\
**Post date:** [August 31, 2023, 7:36pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/7 "2023-08-31T19:36:21Z")

</div>

I tried the Hairless implementation, but seems to work very unreliable. Despite many attempts, only a few times was I able to have sound as output on Windows.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [August 31, 2023, 8:22pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/8 "2023-08-31T20:22:42Z")

</div>

Have you tried a Serial.begin to set the baud rate, followed by a two second delay.

Yes I agree that the R4 is not very stable when using serial ports. Especially on the 1.xx IDE.

---

<div class="post-metadata">

**Author:** ![yashique](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/yashique/32/1023067_2.png) [@yashique](https://forum.arduino.cc/u/yashique)\
**Post date:** [December 9, 2023, 4:48pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/9 "2023-12-09T16:48:37Z")

</div>

This example did not work for me on the r4 wifi.  
Hairless doesn't pick up any messages from the serial port.  
I'm not sure what I'm missing here..

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [December 9, 2023, 5:38pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/10 "2023-12-09T17:38:01Z")

</div>

> [@yashique](#):
>
> I'm not sure what I'm missing here..

You are missing any detail about your project.  
So for a start :-  
What OS is your computer using?

---

<div class="post-metadata">

**Author:** ![yashique](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/yashique/32/1023067_2.png) [@yashique](https://forum.arduino.cc/u/yashique)\
**Post date:** [December 9, 2023, 5:45pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/11 "2023-12-09T17:45:30Z")

</div>

I am on Windows 11. I have used Hairless before on a similar project (used an arduino mega for that one).  
Apart from that, I'm trying to run the code you provided above to test if I'm able to send midi messages to hairless via USB using the r4 wifi.

I've set the baud rate on hariless to 115200 but still nothing..

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [December 9, 2023, 5:51pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/12 "2023-12-09T17:51:34Z")

</div>

> [@yashique](#):
>
> I am on Windows 11.

Sorry I know nothing about Microsoft I was using a Mac.

All I know is that Windows running some kinds of virus protection can sometimes stop the WI-Fi from working. Try a forum search for this, especially ones complaining about very long compile times.

---

<div class="post-metadata">

**Author:** ![yashique](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/yashique/32/1023067_2.png) [@yashique](https://forum.arduino.cc/u/yashique)\
**Post date:** [December 9, 2023, 5:57pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/13 "2023-12-09T17:57:26Z")

</div>

But there's a whole thread you were active on talking about issues with the r4 wifi's serial communication. [MIDI-library works on Minima but not on WIFI](https://forum.arduino.cc/t/midi-library-works-on-minima-but-not-on-wifi/1165783)

So I'm finding it hard to understand how you got around that and got this code to work.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [December 9, 2023, 6:03pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/14 "2023-12-09T18:03:08Z")

</div>

> [@yashique](#):
>
> So I'm finding it hard to understand how you got around that and got this code to work.

**I am on a Mackintosh computer**  
I have always been on a. Macintosh computer, also I run IDE 1.8.19.

Understand now why you might be having problems that I do not have?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 6, 2024, 6:03pm UTC](https://forum.arduino.cc/t/arduino-r4-midiusb/1163393/15 "2024-06-06T18:03:16Z")

</div>

Closed on June 6, 2024, 6:03pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
