{"id":819,"date":"2018-04-29T21:02:47","date_gmt":"2018-04-29T13:02:47","guid":{"rendered":"https:\/\/usr.nkust.org\/?p=819"},"modified":"2018-04-29T21:02:47","modified_gmt":"2018-04-29T13:02:47","slug":"microbit-mu-python-introduction","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2018\/04\/29\/microbit-mu-python-introduction\/","title":{"rendered":"\u3010micro:bit\u3011\u5c0f\u5de7\u7684MU\u7de8\u8f2f\u5668\uff0c\u7528Python\u4f86\u958b\u767cmicro:bit\u7a0b\u5f0f"},"content":{"rendered":"<p>\u4f7f\u7528\u4e86micro:bit\u4e00\u6bb5\u6642\u9593\u4e4b\u5f8c\uff0c\u5728\u4f60\u5beb\u7684\u7a0b\u5f0f\u6108\u4f86\u6108\u8907\u96dc\u7684\u6642\u5019\uff0c\u4e0d\u77e5\u9053\u6703\u4e0d\u6703\u89ba\u5f97\u7a4d\u6728\u5728\u8a2d\u8a08\u4e0a\u6709\u4e00\u4e9b\u4e0d\u4fbf\uff0c\u751a\u81f3\u89ba\u5f97\u5728\u653e\u7f6e\u7a4d\u6728\u7684\u6642\u5019\u6709\u4e00\u4e9b\u9ebb\u7169\uff1f\u5982\u679c\u6c92\u6709\u7684\u540c\u5b78\uff0c\u53ef\u4ee5\u9023\u7dda\u5230\u3010<a href=\"http:\/\/drho.club\/2018\/04\/app-inventor-poker-02\/\">\u9019\u7bc7\u6559\u5b78 \uff0c\u64b2\u514b\u724c\u88dc\u724c\u7a0b\u5f0fAPP Inventor<\/a>\u3011\u9ad4\u6703\u4e00\u4e0b\uff0c\u770b\u770b\u4ec0\u9ebc\u6bd4\u8f03\u5927\u7684\u7a0b\u5f0f\u7684\u7a4d\u6728\u6703\u53ef\u6015\u6210\u4ec0\u9ebc\u6a23\u5b50\u3002\u4e0d\u904e\u6c92\u554f\u984c\uff0c\u5176\u5be6micro:bit\u4e5f\u662f\u53ef\u4ee5\u4f7f\u7528\u55ae\u7d14\u7684\u6587\u5b57\u5f0f\u7a0b\u5f0f\u8a9e\u8a00\u4f86\u7de8\u5beb\u7a0b\u5f0f\uff0c\u5176\u5be6\u6700\u53d7\u6b61\u8fce\u7684\u9664\u4e86Javascript\u4e4b\u5916\uff0c\u5c31\u662fPython\u4e86\u3002<\/p>\n<p>\u5728\u5b98\u7db2\u4e2d\u6211\u5011\u5e73\u6642\u9078\u7528\u7684\u8996\u89ba\u5316\u7de8\u8f2f\u5668\u4e4b\u4e0b\uff0c\u6709\u4e00\u500bPython\u7684\u7de8\u8f2f\u5668\uff0c\u9032\u5165\u756b\u9762\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-821 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2028.png\" alt=\"\" width=\"702\" height=\"279\" \/><\/p>\n<p>\u9ede\u9078\u300c\u4f86\u5beb\u500b\u7a0b\u5f0f\u5427\u300d\u6309\u9215\uff0c\u5373\u53ef\u9032\u5165Python\u7de8\u8f2f\u5668\u7684\u4ecb\u9762\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-822 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2030.png\" alt=\"\" width=\"650\" height=\"428\" \/><\/p>\n<p>\u9019\u500b\u4ecb\u9762\u5f88\u7c21\u55ae\uff0c\u4e2d\u9593\u4e00\u500b\u7a0b\u5f0f\u78bc\u7de8\u8f2f\u5668\uff0c\u4f7f\u7528\u7684\u662fPython\u7684\u8a9e\u6cd5\u4f86\u8a2d\u8a08\u7a0b\u5f0f\uff0c\u800c\u4e0a\u9762\u7684\u5e7e\u500b\u6309\u9215\u6700\u91cd\u8981\u7684\u5c31\u662f\u300cDownload\u300d\uff0c\u4e5f\u5c31\u662f\u5728\u5b8c\u6210\u7a0b\u5f0f\u4e4b\u5f8c\u8981\u4e0b\u8f09\u5beb\u5165\u5230micro:bit\u7684\u52d5\u4f5c\u3002\u4e00\u958b\u59cb\u9032\u5165\u4e4b\u5f8c\u6709\u4e00\u500b\u9810\u8a2d\u7684\u7a0b\u5f0f\uff0c\u5b83\u6703\u4f7f\u7528\u6372\u52d5\u6587\u5b57\u300cHello, World!\u300d\uff0c\u63a5\u8457\u662f\u986f\u793a\u4e00\u500b\u611b\u5fc3\u8a18\u865f\uff0c\u7b49\u5f852\u79d2\u4e4b\u5f8c\u518d\u91cd\u8986\u4e00\u6b21\u3002<\/p>\n<p>\u548c\u5716\u5f62\u5f0f\u7a4d\u6728\u4ecb\u9762\u6700\u4e0d\u4e00\u6a23\u7684\u5730\u65b9\u5728\u65bc\u5b83\u6c92\u6709\u6a21\u64ec\u5668\uff0c\u56e0\u6b64\u5728\u7a0b\u5f0f\u5beb\u5b8c\u4e4b\u5f8c\uff0c\u5012\u5e95\u6709\u6c3b\u6709\u5beb\u932f\u6216\u662f\u7d50\u679c\u6703\u662f\u4ec0\u9ebc\uff0c\u5728\u57f7\u884c\u4e4b\u524d\u90fd\u53ea\u80fd\u7528\u60f3\u50cf\u7684\u65b9\u5f0f\uff0c\u9019\u662f\u8981\u9069\u61c9\u7684\u5730\u65b9\uff0c\u4e0d\u904e\uff0c\u4f7f\u7528Python\u8a9e\u8a00\u5728\u7a0b\u5f0f\u4e0a\uff0c\u5982\u679c\u4f60\u719f\u6089\u4e86\u7a0b\u5f0f\u8a2d\u8a08\u7684\u57fa\u672c\u89c0\u5ff5\u548c\u6280\u5de7\u4e4b\u5f8c\uff0c\u5c31\u6703\u767c\u73fe\u5728\u7de8\u5beb\u7a0b\u5f0f\u7684\u901f\u5ea6\u4e0a\u5feb\u591a\u4e86\u3002\u800c\u66f4\u65b0\u4e00\u6b65\u7684\uff0c\u9084\u6709\u7db2\u53cb\u5011\u63d0\u4f9b\u4e86\u5c08\u7528\u7684Python\u7de8\u8f2f\u5668MU Editor\uff0c\u5176\u7db2\u5740\u70ba\uff1a<a href=\"https:\/\/codewith.mu\/\">https:\/\/codewith.mu\/<\/a>\uff0c\u4e3b\u7db2\u7ad9\u756b\u9762\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-823 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2021.png\" alt=\"\" width=\"700\" height=\"406\" \/><\/p>\n<p>\u9ede\u64ca\u300cDownload Now\u300d\u4e4b\u5f8c\uff0c\u53ef\u4ee5\u770b\u5230\u4e0d\u540c\u4f5c\u696d\u7cfb\u7d71\u4e4b\u5b89\u88dd\u6a94\u6848\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-824 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2040.png\" alt=\"\" width=\"678\" height=\"350\" \/><\/p>\n<p>\u8acb\u4f9d\u7167\u4f60\u7684\u4f5c\u696d\u7cfb\u7d71\u4e0b\u53bb\u6b63\u78ba\u7684\u5b89\u88dd\u7a0b\u5f0f\uff0c\u5b89\u88dd\u4e4b\u5f8c\uff0c\u57f7\u884c\u7684\u7de8\u8f2f\u5668\u756b\u9762\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-825 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2041.png\" alt=\"\" width=\"677\" height=\"460\" \/><\/p>\n<p>\u9664\u4e86\u53ef\u4ee5\u7de8\u8f2f\u7a0b\u5f0f\u7684\u5730\u65b9\u770b\u8d77\u4f86\u6bd4\u8f03\u5c08\u696d\u4e00\u9ede\u4e4b\u5916\uff0c\u4e5f\u591a\u4e86\u4e00\u4e9b\u529f\u80fd\u53ef\u4ee5\u4f7f\u7528\uff0c\u6700\u91cd\u8981\u7684\u662f\u591a\u4e86\u4e00\u500b\u300cCheck\u300d\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u771f\u6b63\u57f7\u884c\u7a0b\u5f0f\u4e4b\u524d\u5e6b\u6211\u5011\u6aa2\u67e5\u8a9e\u6cd5\u7684\u6b63\u78ba\u6027\u3002\u4ee5\u4e0b\u662f\u7a0b\u5f0f\u78bc\u7684\u7bc4\u4f8b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-826 aligncenter\" src=\"https:\/\/usr.nkust.org\/wp-content\/uploads\/2018\/04\/2018-04-29_2046.png\" alt=\"\" width=\"677\" height=\"459\" \/><\/p>\n<p>\u5982\u7bad\u982d\u6240\u793a\uff0c\u540c\u5b78\u5011\u53ef\u4ee5\u5148\u6309\u4e0b\u300cCheck\u300d\u770b\u770b\u8a9e\u6cd5\u6709\u6c92\u6709\u6253\u932f\u7684\u5730\u65b9\uff0c\u7136\u5f8c\u518d\u6309\u4e0b\u300cFlash\u300d\u6309\u9215\u5c31\u53ef\u4ee5\u628a\u7a0b\u5f0f\u5beb\u5230micro:bit\u4e2d\u4e86\u3002\u4ee5\u4e0b\u662f\u6aa2\u67e5\u6309\u9215\u8f38\u5165\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff1a<\/p>\n<p>[code]<br \/>\nfrom microbit import *<\/p>\n<p>while True:<br \/>\n  if button_a.is_pressed():<br \/>\n    display.show(Image.HAPPY)<br \/>\n  elif button_b.is_pressed():<br \/>\n    display.show(Image.SAD)<br \/>\n  else:<br \/>\n    display.show(Image.HEART)<br \/>\n[\/code]<\/p>\n<p>MU Editor\u4f7f\u7528\u7684\u662fMicroPython\uff0c\u5b83\u7684\u8a73\u7d30\u8aaa\u660e\u53ef\u4ee5\u5230\u9019\u500b\u7db2\u7ad9\u770b\u770b\uff1a<a href=\"https:\/\/microbit-micropython.readthedocs.io\/en\/0.9\/index.html\">https:\/\/microbit-micropython.readthedocs.io\/en\/0.9\/index.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u4e86micro:bit\u4e00\u6bb5\u6642\u9593\u4e4b\u5f8c\uff0c\u5728\u4f60\u5beb\u7684\u7a0b\u5f0f\u6108\u4f86\u6108\u8907\u96dc\u7684\u6642\u5019\uff0c\u4e0d\u77e5\u9053\u6703\u4e0d\u6703\u89ba\u5f97\u7a4d\u6728\u5728\u8a2d\u8a08\u4e0a\u6709\u4e00\u4e9b\u4e0d\u4fbf\uff0c\u751a\u81f3\u89ba\u5f97\u5728\u653e\u7f6e\u7a4d\u6728\u7684\u6642\u5019\u6709\u4e00\u4e9b\u9ebb\u7169\uff1f\u6c92\u95dc\u4fc2\uff0c\u6211\u5011\u9084\u6709Python\u7a0b\u5f0f\u53ef\u4ee5\u7528\u4f86\u958b\u767cmicro:bit\u5594\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[218],"tags":[220,225],"class_list":["post-819","post","type-post","status-publish","format-standard","hentry","category-218","tag-microbit","tag-mu-editor"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}