{"id":332,"date":"2011-12-17T09:24:59","date_gmt":"2011-12-17T08:24:59","guid":{"rendered":"http:\/\/stigern.net\/blog\/?p=332"},"modified":"2011-12-20T07:22:27","modified_gmt":"2011-12-20T06:22:27","slug":"arduino-leds-that-blinks-to-the-music","status":"publish","type":"post","link":"https:\/\/stigern.net\/blog\/arduino-leds-that-blinks-to-the-music\/","title":{"rendered":"Arduino, LEDs that blinks to the Music!"},"content":{"rendered":"<p>I always wanted to make something out of the microphone sensor I got, it&#8217;s just been laying in a compartment-box until recently when I got the idea of a music beat blinker.<\/p>\n<p><a href=\"http:\/\/stigern.net\/images\/2011\/arduinobeatshd.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"Arduino Beats\" src=\"http:\/\/stigern.net\/images\/2011\/arduinobeats.jpg\" alt=\"\" width=\"300\" height=\"254\" \/><\/a><\/p>\n<p>Basically it just reads the analog value from the mic and converts it to a 0-1023 value, but since the microphone sensor I got is meant for 12 volts, it only ranges from 0 &#8211; 5-600 on 5 volts. But it works just as good, only it&#8217;s not as sensitive as it should be. When playing music that is never a problem hehe.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"http:\/\/stigern.net\/images\/2011\/explanation.jpg\" alt=\"\" width=\"200\" height=\"213\" \/><\/p>\n<p>The microphone sensor I use is one I found on eBay some time ago, just search for &#8220;Arduino Sound Sensor Module&#8221; they cost around 5$. And are very easy to use, only ground it and feed it with 5 volts and stick the output to a analog input on the Arduino. I&#8217;ll also post the program code for the Arduino, it&#8217;s the same thats used in the video below. If you want to make something like this yourself using my example, you only need 5 LEDs or more. And just wire them to the digital pins 2-5, and of course the mic to analog 0. Code example can be found in the bottom of this article.<\/p>\n<p>Here is a video showing the LEDs blinking to the music.<\/p>\n<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/1lAyXiVFdZc?rel=0&amp;hd=1\" frameborder=\"0\" width=\"562\" height=\"317\"><\/iframe><\/p>\n<p>Program code example:<\/p>\n<p>[codesyntax lang=&#8221;cpp&#8221; lines=&#8221;no&#8221; blockstate=&#8221;collapsed&#8221;]<\/p>\n<pre>int micValue = 0; \/\/ Store the readings here.\r\nvoid setup()\r\n{\r\n\/\/ Settings the pins for output to leds.\r\npinMode(2, OUTPUT);\r\npinMode(3, OUTPUT);\r\npinMode(4, OUTPUT);\r\npinMode(5, OUTPUT);\r\n}\r\n\r\nvoid loop()\r\n{\r\n\/\/ Lets read from the mic\r\nmicValue = analogRead(0);\r\n\r\n\/\/ Then choose what leds to turn\r\n\/\/ on and off.\r\nif (micValue &gt; 410)\r\n{\r\ndigitalWrite(2, HIGH);\r\n\r\n}\r\nelse\r\n{\r\ndigitalWrite(2, LOW);\r\n}\r\n\r\nif (micValue &gt; 520)\r\n{\r\ndigitalWrite(3, HIGH);\r\n\r\n}\r\nelse\r\n{\r\ndigitalWrite(3, LOW);\r\n}\r\n\r\nif (micValue &gt; 580)\r\n{\r\ndigitalWrite(4, HIGH);\r\n\r\n}\r\nelse\r\n{\r\ndigitalWrite(4, LOW);\r\n}\r\n\r\nif (micValue &gt; 610)\r\n{\r\ndigitalWrite(5, HIGH);\r\n\r\n}\r\nelse\r\n{\r\ndigitalWrite(5, LOW);\r\n}\r\n\r\n}<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I always wanted to make something out of the microphone sensor I got, it&#8217;s just been laying in a compartment-box until recently when I got the idea of a music beat blinker. Basically it just reads the analog value from the mic and converts it to a 0-1023 value, but since the microphone sensor I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,4],"tags":[16,236,237,235,26,95,30,238,75,239,61],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-arduino-electronics","category-electronics","tag-arduino","tag-beat","tag-blink","tag-disco","tag-guide","tag-how","tag-led","tag-mic","tag-sensor","tag-sound","tag-tutorial"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/comments?post=332"}],"version-history":[{"count":17,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":362,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions\/362"}],"wp:attachment":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}