{"id":631,"date":"2023-03-17T22:27:15","date_gmt":"2023-03-17T22:27:15","guid":{"rendered":"http:\/\/bussigel.com\/newinstruments\/?page_id=631"},"modified":"2025-10-24T01:33:00","modified_gmt":"2025-10-24T05:33:00","slug":"digital-outputs","status":"publish","type":"page","link":"https:\/\/bussigel.com\/sonicarts\/digital-outputs\/","title":{"rendered":"digital outputs"},"content":{"rendered":"\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"616\" src=\"http:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/09\/6.png\" alt=\"\" class=\"wp-image-749\" style=\"width:489px;height:auto\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/09\/6.png 1024w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/09\/6-300x180.png 300w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/09\/6-768x462.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Connect the Anode (+) or longer leg of the LED to one of your digital output pins \u2014 in this case Pin 9. Connect the&nbsp;shorter, or cathode, leg to ground through a 220\u03a9 resistor (red&nbsp;red&nbsp;brown&nbsp;gold).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you play the MIDI note associated with pin 9, the pin is turned on, or set to HIGH, and will send 3.3v through the LED and the resistor, completing the circuit to ground. Your LED should turn on! Let\u2019s look at the code\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create an array of NoteLED objects that receive midi note events from the computer to send 3.3 volts to a pin on the arduino\n\nNoteLED leds&#91;]{ \n{9, 70}, \/\/ pin 9: LED output (midi note Bb4 or 70) \n};<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create a NoteLED object and set up an array, leds[]. The array lets you easily add more leds if you want. Next specify the pin (9) and the MIDI note that the pin responds to, note Bb4 (or midi note 70). So, what if you wanted to add 2 more LEDs? You code would look like this&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create an array of NoteLED objects that receive midi note events from the computer to send 3.3 volts to a pin on the arduino\n\nNoteLED leds&#91;]{ \n{9, 70}, \/\/ pin 9: LED output (midi note 70)\n{8, 69}, \/\/ pin 8: LED output (midi note 69)\n{7, 68}, \/\/ pin 7: LED output (midi note 68)\n};<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\" style=\"grid-template-columns:37% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"418\" height=\"640\" src=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image.png\" alt=\"\" class=\"wp-image-797 size-full\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image.png 418w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image-196x300.png 196w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">If you are using Max, sending a midi note to NoteLED might look strange at first. We are actually sending a 2 item list to the [noteout] object. When you turn the toggle on it sends a 1, which populates the variable ($1) in the list, sending (70 1) to the noteout object. The 70 is the note number, and the 1 is to turn the note ON. When you turn the toggle off it sends a 0 and the noteout object receives (70 0) with the 0 turning the note (and the LED) OFF. <\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Expanding Digital Outputs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the same NoteLED code to drive a small vibration motor. Connect one leg of the motor (it really doesn\u2019t matter which leg in this case) to power (red) and the&nbsp;other leg to ground through a 10K resistor. You won\u2019t be able to control the speed of the motor, but you\u2019ll be able to turn it on and off from your computer by sending a MIDI note. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Transistors<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">A better way to connect a motor uses a new component called.a transistor. A transistor allows you to control higher power devices using the same 3.3v signal that turns on an LED. This is often used for motors and higher power LEDs.<br><\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"682\" data-id=\"719\" src=\"http:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/simple-motor-control.jpg\" alt=\"\" class=\"wp-image-719\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/simple-motor-control.jpg 651w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/simple-motor-control-286x300.jpg 286w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"500\" data-id=\"720\" src=\"http:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/1acc6288c8c249b3132b49ee43006f5cf79c1d00.png\" alt=\"\" class=\"wp-image-720\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/1acc6288c8c249b3132b49ee43006f5cf79c1d00.png 600w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2023\/10\/1acc6288c8c249b3132b49ee43006f5cf79c1d00-300x250.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Relays<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">There is yet another way to expand the functionality of these NoteLED pins. You can connect the digital output pin to a relay. A relay is an electrically operated switch. Relays are used when it is necessary to control a high power circuit using a separate low-power signal (like the output of a microcontroller pin). For more information on relays and arduino, look at <a href=\"https:\/\/lastminuteengineers.com\/one-channel-relay-module-arduino-tutorial\/\">this page<\/a>. (Note: they use a 5v relay, but they make 3.3v relays as well)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"487\" src=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/channel.jpg\" alt=\"\" class=\"wp-image-798\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/channel.jpg 935w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/channel-300x156.jpg 300w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/channel-768x400.jpg 768w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Connect the Anode (+) or longer leg of the LED to one of your digital output pins \u2014 in this case Pin 9. Connect the&nbsp;shorter, or cathode, leg to ground through a 220\u03a9 resistor (red&nbsp;red&nbsp;brown&nbsp;gold). If you play the MIDI note associated with pin 9, the pin is turned on, or set to HIGH, and &hellip; <a href=\"https:\/\/bussigel.com\/sonicarts\/digital-outputs\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">digital outputs<\/span><\/a><\/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-631","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/comments?post=631"}],"version-history":[{"count":7,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/631\/revisions"}],"predecessor-version":[{"id":860,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/631\/revisions\/860"}],"wp:attachment":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/media?parent=631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}