Installing MIDI for the Arduino UNO

I am following this tutorial on how to make a drum machine using the Arduino. Except, in this tutorial they use the Arduino Leonard. In this example, they install a MIDI USB launcher that is specific to the Arduino Leonard. I can’t find any packages specific to the Arduino UNO through the board manager, though. I found a MIDI package in the Sketch → Include Libraries → Manage Libraries, but I don’t think that is the same. When I installed that MIDI library, and tried compiling the code that was given, I received this error: ‘MIDIUSB can only be used with an USB MCU’. Here is the code that was made for this project:

Here is the Pastebin of the code, because I couldn’t use the code tags. This code exceeds the forums 9000 character limit.

I included that same MIDI library, but that library came with a couple of other libraries that I ended up taking out, because I couldn’t find them on the ‘Manage Libraries’ dialogue box.

Is there any other MIDI board package that I can install that will still allow me to follow along this tutorial?

Thanks!

The Leonardo uses the ATmega32U4 microcontroller which has built in USB functionality, making it easy to use as a MIDI controller. The Uno uses ATmega328P, which does not have built in USB. This means using an uno for this project is not so easy. However, on the official Uno boards and some clones there is a microcontroller with built in USB, the ATmega16U2. This is normally used only for creating a virtual serial port on your computer to uploading sketches and do serial communication (for example using Serial Monitor) but you can update the firmware on that microcontroller to give your Uno super powers!

Wow, thanks for all that information, Pert! I had no idea the microcontrollers varied that much.

So, what I understood is that on the Uno you wouldnt be able to upload sketches while it was plugged into MIDI software, because the ATmega328P doesn't have built in USB. Is that correct?

Is this a good tutorial to allow it to be done, then?

When you say update the firmware on that Uno, do you mean the boards that have the ATmega16U2 microcontroller?

Again, I appreciate you giving me the knowledge, man!

BayBayMan: So, what I understood is that on the Uno you wouldnt be able to upload sketches while it was plugged into MIDI software, because the ATmega328P doesn't have built in USB. Is that correct?

I don't know about whether it's possible to update the firmware and still be able to upload to the Uno via USB but you can always do Sketch > Upload Using Programmer to upload using an ISP (In System Programming) programmer connected to the ICSP header for the ATmega328P (located near the edge of the Uno on side opposite the USB jack). If you don't have a dedicated programmer but have an extra Arduino you can use it as an "Arduino as ISP".

BayBayMan: Is this a good tutorial to allow it to be done, then?

I have no experience with this. Maybe another forum member who has done this will chime in with some input. You might also take a look at https://github.com/NicoHood/HID

BayBayMan: When you say update the firmware on that Uno, do you mean the boards that have the ATmega16U2 microcontroller?

Yes, I mean updating the firmware running on the ATmega16U2 on the Uno. This is the little square chip just behind the USB jack. I've never done it but my understanding is there are two ways of updating the firmware, DFU via the USB cable or using an ISP (in system programming) programmer, such as Arduino as ISP or USBasp connected to the ICSP header next to the ATmega16U2. That tutorial they are using the AVRISP MKII but you can use any programmer. Clone Unos frequently have the CH340 USB-serial chip instead of the ATmega16U2 and you can't change the firmware on that chip, it only works as USB-serial, rather than being a general purpose microcontroller that can be programmed however you like as the ATmega16U2 is.