Introduction: Recompile (Rename) and Flash HIDUINO With ISP to Turn Your Arduino Into an HID (usb-midi) Device

Picture of Recompile (Rename) and Flash HIDUINO With ISP to Turn Your Arduino Into an HID (usb-midi) Device

HIDUINO is a firmware (code) made to run on the microcontrollers Atmega8u2 (Arduino UNO Rev 2 -and previous- or Mega2560) and Atmega16u2 (Arduino UNO Rev3).

These are the ones in charge of getting the computer and the boards to talk to each other. When the normal firmware runs on them (usbserial), we are allowed to upload sketches to modify the behaviour of the board, read inputs, write outputs and send messages via Serial ports, through the USB ports of the computer.

HIDUINO replaces this firmware, and allows the board to be presented as a Human Interface Device or HID. These kind of devices are very common, and we use lots of them everyday, such as keyboards, mouses, tactile screens, webcams, joysticks, ecc. What's nice about them is that usually we don't need any specialized drivers, since they are Plug&Play.

So far, the HIDUINO project has developed the code for the board to be recognized as an USB-MIDI device.

At Yaeltex, we realized that HIDUINO is sometimes a little hard to grasp, and the documentation about it is often incomplete, hard to find or not up-to-date, so we decided to put together what we have learned in the process of renaming, recompiling and flashing our own devices, and build this instructable to help whomever might want to do something similar.

This tutorial uses as reference and sometimes quotes of the following excelent tutorials:

AVRDUDE - por LadyAda
HIDUINO - por Dimitri Diakopoulos
HIDUINO via ISP Method - por Dimitri Diakopoulos

Steps 1 to 3 are dedicated to show the process of renaming and recompiling the source code of HIDUINO, in order to give our device a name of our choice, instead of "arduino_midi" or "HIDUINO", which is the default name.

If you aren't interested on renaming your device, then you can skip those, and jump to step 4, where I begin describing how to flash HIDUINO on your board.

Every image on this instructable where an Arduino is shown, was taken from the Fritzing prototyping environment.

Good luck!

Step 1: Recompiling HIDUINO - Intro and SW Requirements

Picture of Recompiling HIDUINO - Intro and SW Requirements


It is finally here!

With this web-app, now permanent on the cloud, you can download a compiled MOCOLUFA firmware, named as you want your device to be named.

Link to the app: Pimp My Mocolufa.

After downloading the hex file, you can upload it just as you did with HIDUINO, jumping to step 4.

MOCOLUFA allows the Arduino to dual-boot, this means, boot as a USB-MIDI device, or a USB-Serial device (to program it with the IDE) just by shorting pins 4 and 6 of the ICSP connector near the usb (see step 4).

No jumper -> USB-MIDI

With the jumper -> USB-Serial



Pimp My Hiduino is offline cause my AWS free tier is over. Until I find a free way to host this app, you will have to follow the instructable to Recompile HIDUINO.


Just use this tool me and Pablo Fullana made to get your renamed and compiled firmware

Pimp My Hiduino

and then skip to step 4 to load into into your Arduino


The precompiled version of HIDUINO is recognized by the computer as "HIDUINO" or "arduino_midi" (latest version). Compiling from scratch, lets us rename the device to a name of our liking.

Software requirements

To rename our controller, we need to download and install Notepad++, which is an excellent text editor for coding, the LUFA 140928 package, in order to have the libraries needed to recompile hiduino, and the last version of the HIDUINO-MASTER source code (there is a button that reads "Download .ZIP" at the right-bottom-ish on the site)

Step 2: Recompiling HIDUINO - Step 1 - Relocate Libraries, Rename and Adequate Makefile

Picture of Recompiling HIDUINO - Step 1 - Relocate Libraries, Rename and Adequate Makefile

Make sure you have downloaded the right LUFA 140928 package, and extract the whole folder into the hiduino-master folder:


Then copy the whole folder:




I had trouble compiling, when there are other projects on this, folder, so, just to make sure, delete every other folder inside the Projects folder.

Go into the 'arduino_midi' folder and open (with Notepad++) the file 'Descriptors.c'.

Go to line 263, where you can change the ProductString, which is the name the device will have:

const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"TRACTORCITO");

Then you can do the same with the manufacturer's name, changing the string at the end of line 257:

const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"YAELTEX");

We have named our Traktor DJ mixer :)

Save the file.

Then, in the same folder, open with Notepad++ the file named 'makefile'. This file contains a series of instructions for the compilation of the project.

Now you should edit line 36 and leave it as follows, depending on the model you are using:

- UNO:

36- ARDUINO_MODEL_PID = 0x0001

- Mega2560:

36- ARDUINO_MODEL_PID = 0x0010

IMPORTANT! DO NOT modify the makefile structure. This means, DO NOT add new lines, or tabs, or spaces, only comment with a # the line you need to comment, and erase the # if you need to uncomment it.

Step 3: Recompiling HIDUINO - Step 2 - Make!

Picture of Recompiling HIDUINO - Step 2 - Make!

Open a command window.

- Windows: Start menu, type 'cmd' and hit Enter, or go to 'Run -> cmd' and hit Enter.
- MacOS: Go to 'Utilities -> Terminal'

Navigate with the 'cd' command to the 'arduino_midi' project folder.


`cd C:\Users\Username\Desktop\hiduino-master\lufa-LUFA-140928\Projects\arduino_midi`

and then type


and hit Enter.

Compiling should take 5-10 seconds. Once completed, we should see the message shown on image 3.

Take the 'arduino_midi.hex' file that now should be inside the project folder, rename it with the same name you gave the device on the Descriptors.c file, and move it to a folder where you'll keep the project firmwares.

It is now ready to be flashed to your Arduino!

Common errors and likely solutions

- Error: When compiling, 'make' throws an Error 2, saying it can't recognize a parameter in a function at line 74 of "arduino_midi.c":

73- // Disable clock division
74- clock_prescale_set(clock_div_1);

This happens because the variable clock_div_1 is not defined on some microcontrollers (bug in avr/power.h).

Solution: Comment line 74 with // at the beggining of the line, and paste the next code right below:

CLKPR = (1 << CLKPCE);
CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);

The whole thing should look like this:

/* Disable clock division */
// Implementation missing - // clock_prescale_set(clock_div_1);
CLKPR = (1 << CLKPCE);
CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);

Try 'make' again from the command window.

- Error: When compiling, 'make' throws an Error 1, on the file "Descriptors.o".
Solution: It appears to be that the quotation marks on the line where we changed the name (line 263, file 'Descriptors.c') need to be straight (" ") and not inclined (“ ”) change the quotation marks and try 'make' again.

Step 4: Flash HIDUINO - Intro and SW Requirements

Picture of Flash HIDUINO - Intro and SW Requirements

Now, I present the steps to flash the HIDUINO firmware to the Arduino UNO (microcontrollers Atmega8u2/16u2) or Arduino Mega (Mega2560).

Once flashed, you will loose the possibility to load any more sketches with the Arduino IDE through the normal USB port. To do this, you must reflash the microcontroller with its original firmware (usbserial).

However, it is possible to flash the main microcontroller (the long one, further from the usb port) with the Arduino IDE and an ISP programmer (or another Arduino), selecting the right programmer "Tools -> Programmer" and then "File-> Upload using programmer" ("Program-> Upload using programmer" from IDE 1.6.5). To do this, the programmer must be connected to the ICSP port next to the long microcontroller.

In any case, make sure to upload your final sketch to the board, before flashing HIDUINO.

Software requirements to flash HIDUINO:


- WinAVR (in order to use avrdude).


- Crosspack (in order to use avrdude).


- Last version of Arduino IDE

- Last version of the Arduino MIDI Library.

Step 5: Flashing HIDUINO - Required Hardware and Wiring

Picture of Flashing HIDUINO - Required Hardware and Wiring

As a programmer one could use a off the shelf ISP programmer like the AVRISPMKII, or another Arduino (tested with Arduino UNO and Duemilanove).

If you are using a commercial programmer, skip the wiring section and make sure to plug the connector with the red cable away from the board's USB port (pin 1 of ISP connector).


If you want to use another Arduino as ISP programmer, you need to wire some cables from it to the ISP port close to the USB port of the Arduino to-be-flashed.

Figure 1 shows the programmer board, with the wires coming out of Pins 10 (Reset), 11 (MOSI), 12 (MISO), 13 (SCLK), 5V and GND.

Take note that it is also needed, in order for the Arduino to work as a programmer, a 10uF electrolytic capacitor with its positive pin to Reset, and its negative pin to Ground.

The jumper wires coming out of the programmer, need to form a connector like the one shown in Figure 2.

Figure 3 shows the arduino to-be-flashed. I suggest using Red and Black jumper wires for 5V and GND respectively. Then you can remember to plug the red cable away from the USB port.

In the pictures you can see the correspondance of the connector in Figure 2 to the actual ISP port, and the final connection (last picture)

Step 6: Flashing HIDUINO - Step 0 - About AVRDUDE

Picture of Flashing HIDUINO - Step 0 - About AVRDUDE

If you type 'avrdude' on the command line you'll get the command options and what each of them mean.

I explain quickly the most important ones, for the task we want to accomplish, but if you just can't help it and need to read EVERYTHING about avrdude, LadyAda has an excellent tutorial about it.

AVRDUDE is the command used to flash, among other actions, nearly every AVR chip.

It has several options:

“-p” This is just to tell it what microcontroller its programming. For example: at90usb162 or at90usb82.

“-P” This is the communication port to use to talk to the programmer. Normally we'll use usb for USB (if you use the AVRISPMKII), COMX for a virtual serial port on Windows, or /dev/cu.usbserial or /dev/cu.KeySerial1 for serial on MacOSX.

“-b” This is for overriding the serial baud rate for programmers like the STK500. Leave at 19200 if you are using an Arduino as programmer, otherwise do not use this option

"-c" Here is where we specify the programmer type. Choose if you're using an arduino or avrispmkii.

“-U” OK this one is the important command. Its the one that actually does the programming.


- is either flash (memory where the code is saved, which we use to "flash" hiduino), eeprom, hfuse (high fuse), lfuse (low fuse), o efuse (extended fuse).
r|w|v - could be r (read), w (write), v (verify)
- is, well, the file that you want to write to or read from.
[:format] (optional) means theres an optional format flag. We will always be using "Intel Hex" format, so use i

“-v” This gives you 'verbose' case you want to debug something. If you want you can use it.

“-F” This overrides the signature check to make sure the chip you think you're programming is. We use it in some cases when we get an error such "Device signature check failed".

Step 7: Flash HIDUINO - Step 1 - Upload the ISP Programmer Code

Picture of Flash HIDUINO - Step 1 - Upload the ISP Programmer Code

If you will use a commercial programmer like the AVRISPMKII, skip this step.

If you are using an Arduino, and you already have the wiring set-up, we only need now to load the code to the Arduino, for it to behave as an ISP programmer.

- Execute the Arduino IDE and open the "Arduino as ISP" example, from the menu "File -> Examples -> Arduino as ISP".

- Plug the Arduino to a the computer with an USB cable.

On windows, if it's the first time you plug it, you should wait until the automatic drivers are installed, and write down which virtual serial port the Arduino is assigned to. If you miss this, you can check it later on the Device Manager under "COM Ports", or on the Arduino IDE from the menu "Tools -> Port".

On a Mac, go to the arduino IDE to check which serial port was the board assigned to.

- Select the appropiate board and port on the menu "Tools -> Board" and "Tools -> Port". For example: Board -> "Arduino UNO", Port - "COM10".

- Load the sketch to the Arduino (Ctrl -or ⌘- +U).

Step 8: Flashing HIDUINO - Step 2 - Execute Avrdude and Flash!

Picture of Flashing HIDUINO - Step 2 - Execute Avrdude and Flash!

Open a command window.

- Windows: Start menu, type 'cmd' and hit Enter, or go to 'Run -> cmd' and hit Enter.
- MacOS: Go to 'Utilities -> Terminal'

Navigate to the folder where you placed the hex file you want to flash. Example: "arduino_midi.hex" "TRACTORCITO.hex"

'cd Location'

Execute ONE the following commands, according to which firmware you want to flash, and which programmer you are using.

Remember to change the programming port and the microcontroller id, based on your needs.

- To flashHIDUINO:

- Arduino as ISP programmer

avrdude -p at90usb162 -P COM10 -b 19200 -c arduino -U flash:w:arduino_midi.hex -v -F

- AVRISPMKII programmer

avrdude -p at90usb162 -P usb -c avrispmkii -U flash:w:arduino_midi.hex -v -F

- To flashusbserial (to be able to load sketches through USB again)

- Arduino as ISP programmer

avrdude -p at90usb162 -b 19200 -P COM10 -c arduino -U flash:w:usbserial_uno_16u2.hex -v -F

- AVRISPMKII programmer

avrdude -p at90usb162 -P usb -c avrispmkii -U flash:w:usbserial_uno_16u2.hex -v -F

Hitting Enter after pasting one of these commands will trigger the programming process and verifying processes. Once finished, we should see a message such as the one on figure 3.

Common errors and likely solutions

- Error: stk500_getsync(): not in sync: resp=0x15 o 0x00

Solution: Missing 10uF capacitor between RESET and GND on the programmer arduino.

- Error: Device signature: 0xXXXXXX Expected signature for BLABLA is 0xZZZZZZ.

Solution: Add to the end of the command the switch -F, in order to override this check.

- Error: avrdude: ser_open(): can't open device "\\.\COMX"

Solution: Arduino to-be-flashed or programmer not connected.

Step 9: Farewell

That's all folks!

I hope this instructable was useful and easy to follow, and that it helped you to successfully rename, recompile and flash hiduino , and now you have a working and personalized MIDI controller.

Please leave any comments, suggestions, insults, doubts, or any question regarding this tutorial, that will help me improve it.



gabolight (author)2017-11-13

HUGE THX!!! Nice and easy!!! THX!!

Deathinsector. (author)2017-07-06

How do I put new sketches on MIDI Arduino via ISP Arduino exactly?

Fardenco (author)2017-03-09


It seems like "Pimp my Hiduino" is offline now, is this permanent ?

Thank you

fgrassano (author)Fardenco2017-03-10

Hello, yes, it's offline because my free tier of AWS is over... Until I find a free way to host this app, it will be offline. Sorry for that. I will take it off the instructable

Rominshky (author)2017-02-17


I followed the instructions step by step. After flashing, my
arduino mega2560 is not recognized as a Midi controller. I can transfer
my codes with IDE and my AVRMKii but not recognized

I have a Mega2560 (original) so i typed in terminal:
Avrdude -p atmega2560 -P usb -c avrispmkii -U flash: w: usbserial_mega_16u2.hex -v -F

Would the problem come from there?

Thanks for your answer

fgrassano (author)Rominshky2017-02-17

Try copying the command as follows:

avrdude -p m2560 -c avrispmkii -P usb -b 115200 -F -U flash:w:usbserial_mega_16u2.hex

Rominshky (author)fgrassano2017-02-17

Thank you for your prompt response.I have the same problem with : avrdude -p m2560 -c avrispmkii -p usb -b 115200 -F -U flash: w: usbserial_mega_16u2.hex

I can use the IDE for the Midi code but it is not recognized as a controller.


I send you a screenshot of my terminal

P.S : The AVR must be connect to the ICSP1 ? is'nt it ?

fgrassano (author)Rominshky2017-02-17

no! that's it sory, you have to program the chip close to the USB port, in the picture you see on step 5 (with the orange rectangles), there are two ISP ports and the one you use to change the USB from serial to midi is ICSP2

Sorry I didn't think of that, then the command remains with the at90usb162 directive as follows:

avrdude -p at90usb162 -c avrispmkii -P usb -b 115200 -F -U flash:w:usbserial_mega_16u2.hex

Rominshky (author)fgrassano2017-02-18

So i tried with ICSP2 on my mega and it's the same problem.

Here's what I did:
1/ Cd "location of my compiled_firmwares folder"
2/ Avrdude -p at90usb162 -c avrispmkii -p usb -b 115200 -F -U flash: w: usbserial_mega_16u2.hex

P.D : You wrote p at90usb162 - it's not m2560 for my mega2650 rev3 ?

Here is the result of my photo terminal

fgrassano (author)Rominshky2017-02-18

Try 19200 instead of 115600. The mega2560, as well as the Uno, has 2 chips on the board, and the one we need to program is the one that handles USB communications, and this one is called Atmega16u2 (or 8u2,depending on the rev of the board).

Rominshky (author)fgrassano2017-02-22

It's okay, I got help from a computer specialist.
For a mega2560 with AVRMKii:

1- in the terminal, change directory to the arduino_midi folder

ex : cd / Users /
name / Desktop / hiduino-master / LUFA-140928 / Projects / arduino_midi

2- Connect your AVR to the ISCP2 port + power up your card

3- Write in the terminal : avrdude -p m16u2 -c avrispmkii -P usb -b 115200 -F -U flash:w:arduino_midi.hex (Remember to validate ;-)

fgrassano (author)Rominshky2017-02-17

Baud rate is 19200, sorry for that

avrdude -p at90usb162 -c avrispmkii -P usb -b 19200 -F -U flash:w:usbserial_mega_16u2.hex

fgrassano (author)Rominshky2017-02-17

hello rominshky!

it sounds as if the flashing process is not being successful, what do you see on the terminal after it ends?

Can you post it here as an image?

Also, try replacing "atmega2560" with "m2560" on the avrdude command

fgrassano (author)fgrassano2017-02-17

Also, I notice some spaces in your command, where there shouldn't be spaces, on the -U section. Try copying the command that follows and see if it works:

avrdude -p m2560 -P usb -c avrispmkii -U flash:w:usbserial_mega_16u2.hex -v -F

DươngH1 (author)2015-10-04

If i use kit Burn-e to flash. How I should config fulse bit ?. (I'm using google translate ??)

fgrassano (author)DươngH12017-02-17

Sory for the late reply, I didn't see the e-mail.

Did you solve this? I'm not really sure about the Burn-e kit.

CarlosT11 (author)2015-08-24

Hello, I really love you description about turning arduino into usb-midi, but I encounter problem when compiling. It says 'make' is not a internal or external command.......

What should I do?

fgrassano (author)CarlosT112015-08-24

Here's how to edit the PATH variable in order to add the path to the 'make' program, once you installed gnuwin32 (which provides linux packages able to run on windows)

CarlosT11 (author)fgrassano2015-08-25

Yes, I have edited the path also, so the "make" command works, but it ask for "avr-size" command, which I couldn't find.

fgrassano (author)CarlosT112015-08-25

Mmm, this is weird. It's difficult to help you not knowing the exact error you are getting, and when you are getting it, meaning which command did you execute when you got this error. You could post a screenshot, or try googling it to see if anyone else has come across this same problem.

I haven't heard of this command before.

Have you installed the WinAVR pack?

CarlosT11 (author)fgrassano2015-08-28

Hello fgrassano, can you hear me?

At last I can only use Atmel Studio to flash, cause I can't use avrdude in my system. but after flashing the hardware still appear as "Mega2560". I really need your help!

fgrassano (author)CarlosT112015-08-28

What is the name of the hex file you used?

Mate, you need to give more information when you ask for help... like which OS you are using...

Also I haven't heard of Atmel Studio being used to flash the Atmega16u2, but maybe it works.

If you are using Windows, I suggest using Atmel FLIP, it's a much easier way to flash hex files to the board.

Arduino's site has a nice tutorial about this:

CarlosT11 made it! (author)fgrassano2015-08-28

I try Atmel FLIP, it can't recognise any USB device just as avrdude.
Because I've now installed Atmel Studio, the AVRISP mkII driver is under "Jungo Connectivity", may be that's why other programmer can't recognise an USB device.

CarlosT11 (author)fgrassano2015-08-28

Hello, I am using Windows 7 64 bit and a new ASRISPmkII. Just because I cannot installed AVR studio 4.11 on my system, so the dealer suggest me to download the updated version and I download Atmel studio 6.

I followed your instruction to rename "arduino_midi" as "carlos_midi.hex" and flash to a 2560 without error reported, but I can't get the name when plugin.

CarlosT11 (author)fgrassano2015-08-26

And I also try to flash hiduino with Atmel Studio, but flashing the hardware still appear as "Mega2560" but not "arduino midi"

CarlosT11 (author)fgrassano2015-08-26

I solved the avr-size problem by assigning path also, but now avrdude command turn out:

open config file "": Invalid argument


fgrassano (author)CarlosT112015-08-24

The problem is that Windows needs directions as to where to find the program 'make', and it seems yours is not finding it.

Check this link:

There's one comment that seems to have the answer you need.

"I donwloaded 'make-3.81.exe' from the following link : link. I executed the 'make-3.81.exe' and a new folder 'GnuWin32' was created under C:\Program Files (x86)\. Then in Windows 7 I did: Start -> cmd -> cd C:\Program Files (x86)\GnuWin32\bin -> make (typed 'make') and the command was recognized. Afterwards I editted the PATH environment variable as you told me and the problem was solved! The 'make' command is now recognized by the system. Thanks for your help!"

CarlosT11 (author)fgrassano2015-08-25

Thanks for your concern. Now I install make-3.81 and the make command works, but this time it ask for 'avr-size' command. What should I do?

About This Instructable




More by fgrassano:Recompile (Rename) and Flash HIDUINO With ISP to Turn Your Arduino Into an HID (usb-midi) DeviceRecompilar (renombrar) Y Cargar HIDUINO Mediante ISP
Add instructable to: