Howto: Arduino Due as MIDI HID device

1) Get the HIDUINO code from: https://github.com/ddiakopoulos/hiduino

2) Get the MIDI library for Arduino at http://sourceforge.net/projects/arduinomidilib/

3) Program the 16u2 chip with ICSP programmer:

../bin/avrdude -C avrdude.conf -c avrispmkII -p m16u2 -P usb -U flash:w:/Users/jouni/Downloads/hiduino-master/Compiled\ Firmwares/HIDUINO_MIDI.hex

To RECOVER I wrote on OS X:

cd /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/firmwares/atmega16u2

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -c usbasp -p m16u2 -U flash:w:Arduino-DUE-usbserial.hex

4) Edit the arduino midi library file MIDI.h and comment row sayin “typedef uint16_t word;” to get rid off compiler error (if occurs).

5) Upload for example the following code to Due:

#include <MIDI.h>
/*
Basic I/O MIDI tutorial
by Franky
28/07/2009
*/
#define LED 13   // LED pin on Arduino board
void setup() {
pinMode(LED, OUTPUT);
MIDI.begin(4);            	// Launch MIDI with default options
// input channel is set to 4
}
void loop() {
digitalWrite(LED,HIGH);     // Blink the LED
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,LOW);
}
#include <MIDI.h>/*  Basic I/O MIDI tutorial  by Franky  28/07/2009*/
#define LED 13   // LED pin on Arduino board
void setup() {  pinMode(LED, OUTPUT);  MIDI.begin(4);            	// Launch MIDI with default options	 // input channel is set to 4}
void loop() {
digitalWrite(LED,HIGH);     // Blink the LED    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,LOW);

}