{"id":850,"date":"2025-10-23T04:50:05","date_gmt":"2025-10-23T08:50:05","guid":{"rendered":"https:\/\/bussigel.com\/sonicarts\/?page_id=850"},"modified":"2025-11-27T19:50:30","modified_gmt":"2025-11-28T00:50:30","slug":"pulse-width-modulation","status":"publish","type":"page","link":"https:\/\/bussigel.com\/sonicarts\/pulse-width-modulation\/","title":{"rendered":"Pulse Width Modulation"},"content":{"rendered":"\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Pulse Width Modulation (PWM) is a technique used to simulate variable output using digital signals. Instead of varying voltage continuously, PWM rapidly switches a digital pin between HIGH and LOW, adjusting the proportion of time it stays HIGH within each cycle\u2014the \u201cduty cycle.\u201d A higher duty cycle means more power delivered on average. On an Arduino, we use PWM to control things like LED brightness or motor speed by varying this duty cycle on specific PWM-capable pins.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\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-full\"><img loading=\"lazy\" decoding=\"async\" width=\"810\" height=\"514\" data-id=\"807\" src=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image-1.png\" alt=\"\" class=\"wp-image-807\" srcset=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image-1.png 810w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image-1-300x190.png 300w, https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/image-1-768x487.png 768w\" sizes=\"auto, (max-width: 810px) 100vw, 810px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" data-id=\"847\" src=\"https:\/\/bussigel.com\/sonicarts\/wp-content\/uploads\/2025\/10\/a1b5f4441f1c8847f8d38183281e0b02.gif\" alt=\"\" class=\"wp-image-847\"\/><\/figure>\n<\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">One thing, be careful to use PWM enabled pins. On the Pro Micro, these are pins 3, 5, 6, 9, &amp; 10 (designated by the squiggly lines in the pinout diagram above). There are no additional components necessary, hook up your LED like normal using a 220Ohm resistor. The Control Surface library that we are using makes it simply to use PWM. Here is all of the code necessary to output PWM on pin 9. <\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>NoteValueLEDPWM led = {\n  9, 72,      \/\/ Pin of the LED (must be PWM pin), Midi Note 72)\n};<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it, now the velocity of midi note 71 will determind the brightness of the LED! <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">multiple leds&#8230; make sure you are using PWM pins (~)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NoteLEDPWM leds&#91;] {\n  {5, 60},\n  {9, 61},\n  {10, 62},\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pulse Width Modulation (PWM) is a technique used to simulate variable output using digital signals. Instead of varying voltage continuously, PWM rapidly switches a digital pin between HIGH and LOW, adjusting the proportion of time it stays HIGH within each cycle\u2014the \u201cduty cycle.\u201d A higher duty cycle means more power delivered on average. On an &hellip; <a href=\"https:\/\/bussigel.com\/sonicarts\/pulse-width-modulation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Pulse Width Modulation<\/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-850","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/850","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=850"}],"version-history":[{"count":3,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/850\/revisions"}],"predecessor-version":[{"id":878,"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/pages\/850\/revisions\/878"}],"wp:attachment":[{"href":"https:\/\/bussigel.com\/sonicarts\/wp-json\/wp\/v2\/media?parent=850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}