{"id":945,"date":"2020-02-15T04:56:13","date_gmt":"2020-02-15T04:56:13","guid":{"rendered":"https:\/\/netlab.com.ph\/?p=945"},"modified":"2020-02-15T04:56:13","modified_gmt":"2020-02-15T04:56:13","slug":"notes-on-microbits-input-output-pins","status":"publish","type":"post","link":"https:\/\/netlab.com.ph\/?p=945","title":{"rendered":"Notes on micro:bit&#8217;s Input\/Output Pins"},"content":{"rendered":"\n<p><strong>What is\nthe difference between digital read pin vs analog read pin?<\/strong><\/p>\n\n\n\n<p>We use digital read pin when we want to\nread a digital (0 or 1) signal from a pin in the microbit board. The general\npurpose input and output (GPIO) &nbsp;pins are\nP0, P1 and P2. Pins P3, P4, P6, P7, P9, and P10 can also be used provided you\ndo not use the onboard LED screen such as scrolling a text message because the pins\nare shared with the onboard LED.<\/p>\n\n\n\n<p>For reference, please consult the official microbit external connection pins page at https:\/\/microbit.org\/guide\/hardware\/pins\/. <\/p>\n\n\n\n<p>We use the analog read pin when we want to read an analog signal source and that signal will be converted to values from &nbsp;0 through 1023. To have an idea on what values are being sent by a sensor to your microbit (for reference purposes), just assign a variable and show that variable directly to the onboard LED screen. The example code shows how this is done: <\/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\/02\/read_pin_value.jpg\" alt=\"\" class=\"wp-image-946\" \/><figcaption>Determining the value of an analog signal.<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>GPIO Shared\nPins Usage<\/strong><\/p>\n\n\n\n<p>As mentioned above,&nbsp; pins P3, P4, P6, P7, P9, and P10 shares the connection with the onboard LED &nbsp;matrix display and also it\u2019s associated ambient light sensing mode. To avoid unwanted signal stray when using these pins as input, disable the on-board LED screen by invoking the block <strong><em>Led Enabled False<\/em><\/strong> on start of your program code. <\/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\/02\/led_display.jpg\" alt=\"\" class=\"wp-image-947\" \/><figcaption>Disable LED display<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Playing\nSounds<\/strong><\/p>\n\n\n\n<p>By default, microbit will play a sound through pin P0. In order to use another pin, such as pin P2, to play a sound, you need to use the <strong><em>Analog Set Pitch Pin<\/em><\/strong> block upon on start.<\/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\/02\/set-pitch.jpg\" alt=\"\" class=\"wp-image-948\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is the difference between digital read pin vs analog read pin? We use digital read pin when we want to read a digital (0 or 1) signal from a pin in the microbit board. The general purpose input and <a href=\"https:\/\/netlab.com.ph\/?p=945\" 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-945","post","type-post","status-publish","format-standard","hentry","category-microbit"],"_links":{"self":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/945","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=945"}],"version-history":[{"count":0,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=\/wp\/v2\/posts\/945\/revisions"}],"wp:attachment":[{"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netlab.com.ph\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}