{"id":1469,"date":"2024-06-25T08:00:00","date_gmt":"2024-06-25T06:00:00","guid":{"rendered":"https:\/\/www.fuhselab.de\/?p=1469"},"modified":"2025-05-27T13:32:41","modified_gmt":"2025-05-27T11:32:41","slug":"arduino-und-midi","status":"publish","type":"post","link":"https:\/\/www.fuhselab.de\/index.php\/2024\/06\/25\/arduino-und-midi\/","title":{"rendered":"Arduino und MIDI"},"content":{"rendered":"\n<p>Der Arduino kann auch MIDI und ist somit auch als \u201cMusikinstrument\u201c nutzbar\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Schaltungsaufbau:<\/strong><\/p>\n\n\n\n<p>MIDI-Pin 2 (schwarzes Kabel) f\u00fchrt zu Ground (GND).<\/p>\n\n\n\n<p>MIDI Pin 4 (wei\u00dfes Kabel) f\u00fchrt \u00fcber einen Widerstand an 5 Volt.<\/p>\n\n\n\n<p>MIDI Pin 5 (gr\u00fcnes Kabel) f\u00fchrt an Arduino-Pin 1.<\/p>\n\n\n\n<p>Die MIDI-Buchse am Steckboard ist ein MIDI-Out und sendet (in meinem Fall) Daten an ein Yamaha Soundmodul.<\/p>\n\n\n\n<p><strong>Arduino-Code f\u00fcr MIDI-Projekt 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  \/\/  Set MIDI baud rate:\n  Serial.begin(31250);\n}\n\nvoid loop() {\n  \/\/ play notes from F#-0 (0x1E) to F#-5 (0x5A):\n  for (int note = 0x1E; note &lt; 0x5A; note ++) {\n    \/\/Note on channel 1 (0x90), some note value (note), middle velocity (0x45):\n    noteOn(0x90, note, 0x45);\n    delay(100);\n    \/\/Note on channel 1 (0x90), some note value (note), silent velocity (0x00):\n    noteOn(0x90, note, 0x00);  \n    delay(100);\n  }\n}\n\n\/\/  plays a MIDI note.  Doesn't check to see that\n\/\/  cmd is greater than 127, or that data values are  less than 127:\nvoid noteOn(int cmd, int pitch, int velocity) {\n  Serial.write(cmd);\n  Serial.write(pitch);\n  Serial.write(velocity);\n}<\/code><\/pre>\n\n\n\n<p><strong>Arduino-Code f\u00fcr MIDI-Projekt 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\nSerial.begin(31250);\n}\n\nvoid loop() {\n\/\/Note on channel 1 (0x90), some note value (note), middle velocity (0x45):\nnoteOn(0x90, 0x59, 0x45);\ndelay(1000);\n\/\/Note on channel 1 (0x90), some note value (note), silent velocity (0x00):\nnoteOn(0x90, 0x59, 0x00);  \ndelay(1000);\n\nnoteOn(0x99, 0x10, 0x45);\ndelay(1000);\nnoteOn(0x99, 0x10, 0x00);\ndelay(1000);\n\n}\n\n\/\/  plays a MIDI note.  Doesn't check to see that\n\/\/  cmd is greater than 127, or that data values are  less than 127:\nvoid noteOn(int cmd, int pitch, int velocity) {\nSerial.write(cmd);\nSerial.write(pitch);\nSerial.write(velocity);\n}<\/code><\/pre>\n\n\n\n<p><strong>Arduino-Code f\u00fcr MIDI-Projekt 3:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int d = 250;\n\nvoid setup() {\n\/\/ Set MIDI baud rate:\nSerial.begin(31250);\n}\n\nvoid loop() {\n\n\/*\nBass Drum = 0x23 \nSnare Drum = 0x26\n*\/\n\nnoteOn(0x99, 0x23, 0x45);\ndelay(d);\nnoteOn(0x99, 0x23, 0x00);\ndelay(d);\nnoteOn(0x99, 0x26, 0x45);\ndelay(d);\nnoteOn(0x99, 0x26, 0x00);\ndelay(d);\nnoteOn(0x99, 0x23, 0x45);\ndelay(d);\nnoteOn(0x99, 0x23, 0x00);\ndelay(d);\nnoteOn(0x99, 0x26, 0x45);\ndelay(d);\nnoteOn(0x99, 0x26, 0x00);\ndelay(d);\nnoteOn(0x99, 0x23, 0x45);\ndelay(d);\nnoteOn(0x99, 0x23, 0x00);\ndelay(d);\nnoteOn(0x99, 0x26, 0x45);\ndelay(d);\nnoteOn(0x99, 0x26, 0x00);\ndelay(d);\n\n}\n\n\/\/  plays a MIDI note.  Doesn't check to see that\n\/\/  cmd is greater than 127, or that data values are  less than 127:\nvoid noteOn(int cmd, int pitch, int velocity) {\n  Serial.write(cmd);\n  Serial.write(pitch);\n  Serial.write(velocity);\n}\n\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Der Arduino kann auch MIDI und ist somit auch als \u201cMusikinstrument\u201c nutzbar\u2026<\/p>\n","protected":false},"author":1,"featured_media":48,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[22],"class_list":["post-1469","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","tag-arduino-gruppe-peine"],"_links":{"self":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/1469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/comments?post=1469"}],"version-history":[{"count":3,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":2799,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/1469\/revisions\/2799"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media\/48"}],"wp:attachment":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media?parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/categories?post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/tags?post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}