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




Introduction: 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!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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!

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

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

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

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

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!

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.


1 Person Made This Project!


  • LED Strip Speed Challenge

    LED Strip Speed Challenge
  • Sculpting Challenge

    Sculpting Challenge
  • Clocks Contest

    Clocks Contest

20 Discussions


6 weeks ago

O mais estranho desse projeto é que não foi enviado nenhum Sketch para o arduino, será que não é mais necessário?!


6 weeks ago

Projeto incompleto, o comando make só funciona no Linux e não do Windows!


1 year ago

Hi! I am new with arduino and hardwares at all and I am having some problems in a project where I want to assemble the head tracker device from this project They use an Arduino pro mini for data processing (with a .ino sketch provided by them), an Arduino USB 2 Serial micro for connecting the pro mino to the pc, and a sensor BNO055 by Adafruit which provides orientation data. I am using the same hardwares instead of the USB converter that in my case is the ft232rl by FTDI. The step I am having problem is the one where I have to flash the HIDUINO firmware (they provide an .hex file) so I can use the whole thing as a MIDI device.

The point is that I just don't understand if I have to overwrite the pro mini's serial firmware or the usb converter's and how it's the correct way to do it, mainly because I can't find examples with the usb converter I have and every new reference I read makes me think of one possibility. In the first link they suggest reading the information in which presents 2 methods: DFU method, that tells I need Atmel Flip software for Windows and ISP method, that I don't know if is my case because I can't find out if my ftdi board is an ISP programmer. I've read about it and in other references also, but I am still not sure about what I have to do.

I hope that someone can help! And sorry for the basic doubts...



1 year ago

Heya. Awesome project. Used a USBTinyIsp to flash the 16U2 on my R3 clone (using the command "avrdude -p at90usb162 -P usb -c usbtiny -U flash:w:jimbotronik.hex -v -F") with a file generated from "Pimp My Mocofula", and the MIDI part works perfectly.

Unfortunately, I'm having issues dual-booting to serial (currently have the 4 and 6 pins bridged using about a foot of wire with a switch attached, but have the same issue using a jumper shunt). When the pins are shorted, the Arduino shows up correctly as a serial device on my Macbook, but trying to upload a sketch gives the following message:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean,
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Users/[redacted]/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"

User configuration file is "/Users/[redacted]/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbmodem1411
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
avrdude done. Thank you.

Problem uploading to board.
I know there's a suggestion to add a capacitor between reset and ground for sync issues, but that doesn't seem relevant in this situation. Any other suggestions?


2 years ago

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


2 years ago

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


3 years ago


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

Thank you


Reply 3 years ago

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


3 years ago


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


Reply 3 years ago

Try copying the command as follows:

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


Reply 3 years ago

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 ?

Capture d&rsquo;écran 2017-02-17 à 21.26.38.png

Reply 3 years ago

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


Reply 3 years ago

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

Capture d&rsquo;écran 2017-02-18 à 13.50.07.png

Reply 3 years ago

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).


Reply 3 years ago

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 ;-)


Reply 3 years ago

Baud rate is 19200, sorry for that

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


Reply 3 years ago

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


Reply 3 years ago

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


4 years ago

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


Reply 3 years ago

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.