{"id":921,"date":"2020-01-17T12:53:07","date_gmt":"2020-01-17T12:53:07","guid":{"rendered":"https:\/\/netlab.com.ph\/?p=921"},"modified":"2020-01-17T12:53:07","modified_gmt":"2020-01-17T12:53:07","slug":"electronics-part-two","status":"publish","type":"post","link":"https:\/\/netlab.com.ph\/?p=921","title":{"rendered":"Electronics &#8211; Part Two"},"content":{"rendered":"\n<p><strong>Controlling External LED with Microbit<\/strong><\/p>\n\n\n\n<p>To control an external LED using the microbit, one has to be careful with the right orientation of the LED pins when supplying power through it. The longer pin of the LED is the anode and should be connected to a positive source. On the microbit, these should be the GPIO pins labeled 0, 1, and 2 &nbsp;(The GPIO 3V will only supply 3 volts to the LED but you can&#8217;t control it.). The shorter pin of the LED is the cathode and should be connected to the Ground (GND) GPIO pin.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It is advisable to add a resistor in series with the LED to limit the current flowing through it and avoid burning the LED. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/ledandres.jpg\" alt=\"\" class=\"wp-image-928\" \/><figcaption>LED in series with a resistor.<\/figcaption><\/figure><\/div>\n\n\n\n<p>In MS Make Code, we control the LED by using the digital write pin block from the Advanced &#8211; Pins section of the toolbox block menu. The code to lit and dim the LED is shown below:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/led-p0.jpg\" alt=\"\" class=\"wp-image-922\" \/><figcaption>CODE: Controlling an external LED<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Attaching a piezo speaker and playing some music with the MIcrobit<\/strong><\/p>\n\n\n\n<p>It is relatively easy to produce tones and music with the BBC Microbit. This can be easily done by attaching&nbsp; a piezo speaker on pin 0 (positive terminal of the speaker) and GND of the GPIO. &nbsp;If you mistakenly connect the speaker terminals in reverse, you won&#8217;t hear an audio.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/speaker_terminals.jpg\" alt=\"\" class=\"wp-image-931\" \/><figcaption>Piezo speaker terminals<\/figcaption><\/figure><\/div>\n\n\n\n<p>In MS Make Code, we make use of the blocks in the Music menu blocks. Our example will play a ringtone using the start melody block on start only once. Feel&nbsp; free to try the other music blocks and have fun.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/netlab.com.ph\/wp-content\/uploads\/2020\/01\/melody.jpg\" alt=\"\" class=\"wp-image-923\" \/><figcaption>CODE: Start Melody Ringtone<\/figcaption><\/figure><\/div>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Controlling External LED with Microbit To control an external LED using the microbit, one has to be careful with the right orientation of the LED pins when supplying power through it. The longer pin of the LED is the anode <a href=\"https:\/\/netlab.com.ph\/?p=921\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-921","post","type-post","status-publish","format-standard","hentry","category-microbit"],"_links":{"self":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=921"}],"version-history":[{"count":0,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/921\/revisions"}],"wp:attachment":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}