{"id":73,"date":"2013-06-12T00:53:04","date_gmt":"2013-06-12T00:53:04","guid":{"rendered":"http:\/\/www.mymidiremotes.com\/home\/?page_id=73"},"modified":"2015-11-29T21:43:54","modified_gmt":"2015-11-29T21:43:54","slug":"midi-arduino-usb","status":"publish","type":"page","link":"http:\/\/www.mymidiremotes.com\/home\/?page_id=73","title":{"rendered":"MIDI + Arduino + USB"},"content":{"rendered":"<p><strong>MIDI+Arduino+USB project gives you a physical MIDI trigger button with USB.<\/strong><\/p>\n<p>Below you&#8217;ll find the links required to turn an Arduino into a MIDI device. The Arduino code I used to send MIDI notes, I was not able at the time of this posting to send MSC with Moco for LUFA, I&#8217;m still working on a fix. Below the code I have some photos of the box. Enjoy.<\/p>\n<p><strong>\u00a0How to make an Arduino into a MIDI device:<\/strong><\/p>\n<p><a href=\"http:\/\/arduino.cc\/en\/Hacking\/DFUProgramming8U2\">http:\/\/arduino.cc\/en\/Hacking\/DFUProgramming8U2<\/a><\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/morecat_lab\/MocoLUFA.html\">Moco for LUFA<\/a><\/p>\n<p><strong>Arduino Code:<\/strong><\/p>\n<p>\/\/ MSC MIDI Arduino controller<br \/>\n\/\/ By Dave Mickey, myMIDIremotes<br \/>\nint buttonPin5 = 12; \/\/Stop<br \/>\nint buttonPin4 = 11; \/\/Reset<br \/>\nint buttonPin3 = 10; \/\/Prev<br \/>\nint buttonPin2 = 9; \/\/Next<br \/>\nint buttonPin1 = 8; \/\/GO<br \/>\nint ledPinON = 2; \/\/LED states that the code loaded correctly<br \/>\nint ledPinMIDI = 3; \/\/LED states that the MIDI was sent<\/p>\n<p>\/\/ variables will change:<br \/>\nint buttonState1 = 1;<br \/>\nint buttonState2 = 1;<br \/>\nint buttonState3 = 1;<br \/>\nint buttonState4 = 1;<br \/>\nint buttonState5 = 1;<\/p>\n<p>void setup() {<br \/>\nSerial.begin(31250); \/\/ Set serial to the MIDI baud rate of 31250<br \/>\npinMode(ledPinMIDI, OUTPUT);<br \/>\npinMode(ledPinON, OUTPUT);<br \/>\npinMode(buttonPin1, INPUT);<br \/>\npinMode(buttonPin2, INPUT);<br \/>\npinMode(buttonPin3, INPUT);<br \/>\npinMode(buttonPin4, INPUT);<br \/>\npinMode(buttonPin5, INPUT);<br \/>\ndigitalWrite(ledPinON, HIGH);<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\ndelay(500);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\nbuttonState1 = digitalRead(buttonPin1);<br \/>\nbuttonState2 = digitalRead(buttonPin2);<br \/>\nbuttonState3 = digitalRead(buttonPin3);<br \/>\nbuttonState4 = digitalRead(buttonPin4);<br \/>\nbuttonState5 = digitalRead(buttonPin5);<\/p>\n<p>if (buttonState1 == 0) {<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\nSerial.write(0x90);<br \/>\nSerial.write(0x01);<br \/>\nSerial.write(0x00);<br \/>\ndelay(250);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\nbuttonState1 = 1; \/\/reset to look for the next input<br \/>\n}<\/p>\n<p>if (buttonState5 == 0) {<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\nSerial.write(0x90);<br \/>\nSerial.write(0x02);<br \/>\nSerial.write(0x00);<br \/>\ndelay(250);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\nbuttonState5 = 1; \/\/reset to look for the next input<br \/>\n}<br \/>\nif (buttonState2 == 0) {<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\nSerial.write(0x90);<br \/>\nSerial.write(0x03);<br \/>\nSerial.write(0x00);<br \/>\ndelay(250);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\nbuttonState2 = 1; \/\/reset to look for the next input<br \/>\n}<\/p>\n<p>if (buttonState3 == 0) {<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\nSerial.write(0x90);<br \/>\nSerial.write(0x04);<br \/>\nSerial.write(0x00);<br \/>\ndelay(250);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\nbuttonState3 = 1; \/\/reset to look for the next input<br \/>\n}<\/p>\n<p>if (buttonState4 == 0) {<br \/>\ndigitalWrite(ledPinMIDI, HIGH);<br \/>\nSerial.write(0x90);<br \/>\nSerial.write(0x05);<br \/>\nSerial.write(0x00);<br \/>\ndelay(250);<br \/>\ndigitalWrite(ledPinMIDI, LOW);<br \/>\nbuttonState4 = 1; \/\/reset to look for the next input<br \/>\n}<br \/>\n\/\/End Loop<br \/>\n}<\/p>\n<p><strong>\u00a0Photos:<\/strong><\/p>\n<div id=\"attachment_80\" style=\"width: 235px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.56.54.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-80\" class=\"size-medium wp-image-80\" alt=\"It works\" src=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.56.54-225x300.jpg\" width=\"225\" height=\"300\" srcset=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.56.54-225x300.jpg 225w, http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.56.54-768x1024.jpg 768w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><p id=\"caption-attachment-80\" class=\"wp-caption-text\">It works<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_81\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.45.14.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-81\" class=\"size-medium wp-image-81\" alt=\"the adafruit pshield  \" src=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.45.14-300x225.jpg\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.45.14-300x225.jpg 300w, http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-11-16.45.14-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-81\" class=\"wp-caption-text\">the adafruit pshield<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_82\" style=\"width: 310px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82\" class=\"size-medium wp-image-82\" alt=\"putting it all together\" src=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-10-09.18.56-300x225.jpg\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-10-09.18.56-300x225.jpg 300w, http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/2013-06-10-09.18.56-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><p id=\"caption-attachment-82\" class=\"wp-caption-text\">putting it all together<\/p><\/div>\n<div id=\"attachment_88\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-11-at-4.54.58-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-88\" class=\"size-medium wp-image-88\" alt=\"Qlab Screen shot\" src=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-11-at-4.54.58-PM-300x187.png\" width=\"300\" height=\"187\" srcset=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-11-at-4.54.58-PM-300x187.png 300w, http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-11-at-4.54.58-PM-1024x640.png 1024w, http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/Screen-Shot-2013-06-11-at-4.54.58-PM.png 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-88\" class=\"wp-caption-text\">Qlab Screen shot<\/p><\/div>\n<p>Video Link: \u00a0<a href=\"http:\/\/www.mymidiremotes.com\/home\/wp-content\/uploads\/2013\/06\/MIDIboxweb-Wi-Fi.m4v\">MIDIbox<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MIDI+Arduino+USB project gives you a physical MIDI trigger button with USB. Below you&#8217;ll find the links required to turn an Arduino into a MIDI device. The Arduino code I used to send MIDI notes, I was not able at the time of this posting to send MSC with Moco for LUFA, I&#8217;m still working on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-73","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/pages\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":9,"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/pages\/73\/revisions"}],"predecessor-version":[{"id":108,"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=\/wp\/v2\/pages\/73\/revisions\/108"}],"wp:attachment":[{"href":"http:\/\/www.mymidiremotes.com\/home\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}