{"id":220,"date":"2013-09-15T18:05:17","date_gmt":"2013-09-15T18:05:17","guid":{"rendered":"http:\/\/mitat.tuu.fi\/?p=220"},"modified":"2014-02-08T09:45:29","modified_gmt":"2014-02-08T09:45:29","slug":"howto-arduino-due-as-midi-hid-device","status":"publish","type":"post","link":"http:\/\/mitat.tuu.fi\/?p=220","title":{"rendered":"Howto: Arduino Due as MIDI HID device"},"content":{"rendered":"<p>1) Get the HIDUINO code from: https:\/\/github.com\/ddiakopoulos\/hiduino<\/p>\n<p>2) Get the MIDI library for Arduino at http:\/\/sourceforge.net\/projects\/arduinomidilib\/<\/p>\n<p>3) Program the 16u2 chip with ICSP programmer:<\/p>\n<p>..\/bin\/avrdude -C avrdude.conf -c avrispmkII -p m16u2 -P usb -U flash:w:\/Users\/jouni\/Downloads\/hiduino-master\/Compiled\\ Firmwares\/HIDUINO_MIDI.hex<\/p>\n<p>To RECOVER I wrote on OS X:<\/p>\n<p>cd\u00a0\/Applications\/Arduino.app\/Contents\/Resources\/Java\/hardware\/arduino\/sam\/firmwares\/atmega16u2<\/p>\n<p>\/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<\/p>\n<p>4) Edit the arduino midi library file MIDI.h and comment row sayin &#8220;typedef uint16_t word;&#8221; to get rid off compiler error (if occurs).<\/p>\n<p>5) Upload for example the following code to Due:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;MIDI.h&gt;\r\n\/*\r\nBasic I\/O MIDI tutorial\r\nby Franky\r\n28\/07\/2009\r\n*\/\r\n#define LED 13   \/\/ LED pin on Arduino board\r\nvoid setup() {\r\npinMode(LED, OUTPUT);\r\nMIDI.begin(4);            \t\/\/ Launch MIDI with default options\r\n\/\/ input channel is set to 4\r\n}\r\nvoid loop() {\r\ndigitalWrite(LED,HIGH);     \/\/ Blink the LED\r\nMIDI.sendNoteOn(42,127,1);  \/\/ Send a Note (pitch 42, velo 127 on channel 1)\r\ndelay(1000);\t \/\/ Wait for a second\r\nMIDI.sendNoteOff(42,0,1);   \/\/ Stop the note\r\ndigitalWrite(LED,LOW);\r\n}\r\n#include &lt;MIDI.h&gt;\/*  Basic I\/O MIDI tutorial  by Franky  28\/07\/2009*\/\r\n#define LED 13   \/\/ LED pin on Arduino board\r\nvoid setup() {  pinMode(LED, OUTPUT);  MIDI.begin(4);            \t\/\/ Launch MIDI with default options\t \/\/ input channel is set to 4}\r\nvoid loop() {\r\ndigitalWrite(LED,HIGH);     \/\/ Blink the LED    MIDI.sendNoteOn(42,127,1);  \/\/ Send a Note (pitch 42, velo 127 on channel 1)    delay(1000);\t \/\/ Wait for a second    MIDI.sendNoteOff(42,0,1);   \/\/ Stop the note    digitalWrite(LED,LOW);\r\n\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0\/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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=220"}],"version-history":[{"count":3,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":244,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=\/wp\/v2\/posts\/220\/revisions\/244"}],"wp:attachment":[{"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mitat.tuu.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}