{"id":14131,"date":"2017-06-28T10:46:53","date_gmt":"2017-06-28T14:46:53","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=14131"},"modified":"2017-06-28T10:46:53","modified_gmt":"2017-06-28T14:46:53","slug":"maximal-annoyance-with-the-bbc-microbit-and-micropython","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2017\/06\/28\/maximal-annoyance-with-the-bbc-microbit-and-micropython\/","title":{"rendered":"maximal annoyance with the BBC micro:bit and MicroPython"},"content":{"rendered":"<p>I just picked up a <a href=\"http:\/\/microbit.org\/\">micro:bit<\/a>, the little educational microprocessor board originally from the BBC. It&#8217;s a nice little unit, though like all educational resources, it&#8217;s sometimes hard to access resources as a non-edu type.<\/p>\n<p>I landed upon <a href=\"https:\/\/micropython.org\/\">MicroPython<\/a>, a Python language subset that runs directly on the micro:bit&#8217;s ARM chip. I rather like the <a href=\"https:\/\/github.com\/mu-editor\/mu\">Mu<\/a> editor:<br \/>\n<a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14132\" src=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52.png\" alt=\"\" width=\"800\" height=\"437\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52.png 800w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52-160x87.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52-320x175.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/Screenshot-from-2017-06-28-10-29-52-768x420.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a>To give the old microcontroller grumps something real to complain about, MicroPython includes a bunch of very high-level functions, such as <a href=\"https:\/\/microbit-micropython.readthedocs.io\/en\/latest\/tutorials\/music.html\">a powerful music and sound module<\/a>. Getting the sound out is easy: just croc-clip a speaker onto the output pads:<\/p>\n<p><a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14133\" src=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb.png\" alt=\"\" width=\"915\" height=\"606\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb.png 915w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb-160x106.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb-320x212.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/microbit-max_annoyance_bb-768x509.png 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/a>(<em>MicroPython warns against using a piezo buzzer as a speaker, but mine worked fine \u00e2\u20ac\u201d loudly and supremely annoyingly \u00e2\u20ac\u201d with a <a href=\"https:\/\/elmwoodelectronics.ca\/products\/large-enclosed-piezo-element-w-wires\">large piezo element<\/a>. Some piezos have a fixed-frequency oscillator attached, but this simple one was great.<\/em>)<\/p>\n<p>This trivial example plays the Nyan Cat theme forever, but every time it loops it gets faster. The beats variable starts at the default 120 bpm, but is increased by one every time:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# nyan but it gets faster\r\nimport music\r\nbeats = 120\r\nwhile True:\r\n    music.set_tempo(bpm=beats)\r\n    music.play(music.NYAN)\r\n    beats = beats + 1\r\n<\/pre>\n<p>This starts out as merely irritating, but quite quickly becomes deeply annoying, and in mere hours become vastly vexing. I&#8217;m sure you&#8217;d only use this power for good \u00e2\u20ac\u00a6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just picked up a micro:bit, the little educational microprocessor board originally from the BBC. It&#8217;s a nice little unit, though like all educational resources, it&#8217;s sometimes hard to access resources as a non-edu type. I landed upon MicroPython, a Python language subset that runs directly on the micro:bit&#8217;s ARM chip. I rather like the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[1747,3060,3061,2540],"class_list":["post-14131","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-annoying","tag-microbit","tag-nyan","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-3FV","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=14131"}],"version-history":[{"count":2,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14131\/revisions"}],"predecessor-version":[{"id":14135,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14131\/revisions\/14135"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=14131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=14131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=14131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}