{"id":2478,"date":"2023-08-03T21:04:00","date_gmt":"2023-08-03T13:04:00","guid":{"rendered":"https:\/\/104.es\/?p=2478"},"modified":"2023-08-03T21:04:00","modified_gmt":"2023-08-03T13:04:00","slug":"microbitmicropython-text-images","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2023\/08\/03\/microbitmicropython-text-images\/","title":{"rendered":"\u3010micro:bit\u3011MicroPython\u7a0b\u5f0f\u7c21\u6613\u5165\u9580"},"content":{"rendered":"\n<p>micro:bit\u53ef\u4ee5\u5229\u7528Python\u4f86\u7de8\u5beb\u5728\u677f\u5b50\u4e0a\u57f7\u884c\u7684\u7a0b\u5f0f\uff0c\u4f46\u662f\u4e26\u4e0d\u662f\u5b8c\u6574\u7684Python\u7a0b\u5f0f\uff0c\u800c\u662fPython\u7a0b\u5f0f\u7684\u5b50\u96c6\u5408\uff0c\u4e00\u500b\u53eb\u505aMicroPython\u7684\u76f4\u8b6f\u5668\u3002\u7279\u5225\u8981\u7559\u610f\u7684\u662f\uff0c\u56e0\u70ba\u6709\u8a31\u591a\u4e0d\u540c\u7684\u958b\u767c\u677f\uff0c\u5305\u62ecESP32\u3001Pico W\u3001HaloCode\u7b49\u7b49\u4e5f\u90fd\u6709\u652f\u63f4MicroPython\uff0c\u4f46\u662f\u5b83\u5011\u4f7f\u7528\u7684\u662f\u4e0d\u540c\u7684\u76f4\u8b6f\u5668\uff0c\u8a9e\u6cd5\u4ee5\u53ca\u64cd\u4f5c\u65b9\u5f0f\u4e5f\u6709\u4e00\u4e9b\u4e0d\u540c\uff0c\u6240\u4ee5\u5728MicroPython\u7684\u76f8\u95dc\u6587\u4ef6\u4e4b\u524d\uff0c\u4e00\u5b9a\u8981\u78ba\u5b9a\u9019\u4efd\u6587\u4ef6\u6240\u9069\u7528\u7684\u958b\u767c\u677f\uff0c\u624d\u53ef\u4ee5\u9806\u5229\u5730\u57f7\u884c\u5594\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u4f86\u6211\u5011\u6240\u6709\u7684\u7a0b\u5f0f\u90fd\u6703\u5728Mu Editor\u4e2d\u7de8\u8f2f\uff0c\u4e26\u5beb\u5165micro:bit\u4e2d\u6e2c\u8a66\u986f\u793a\u7684\u7d50\u679c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8b8a\u63db\u4e0d\u540c\u7684\u8868\u60c5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\n\nwhile True:\n    display.show(Image.HAPPY)\n    sleep(500)\n    display.show(Image.SAD)\n    sleep(500)<\/code><\/pre>\n\n\n\n<p>\u7b2c1\u884c\u7684\u76ee\u7684\u662f\u8981\u532f\u5165\u6240\u6709\u9a45\u52d5micro:bit\u6240\u9700\u8981\u7684\u51fd\u6578\uff08\u4f8b\u5982display\uff09\uff0c\u7b2c3\u884c\u7684\u76ee\u7684\u662f\u8b93\u63a5\u4e0b\u4f86\u7684\u7a0b\u5f0f\u53ef\u4ee5\u6c38\u4e45\u57f7\u884c\u3002<\/p>\n\n\n\n<p>\u5728 \u6c38\u4e45\u57f7\u884c\u7684\u8ff4\u5708\u4e2d\uff0c\u7b2c4\u884c\u986f\u793a\u4e00\u500b\u7b11\u81c9\uff0c\u7b2c5\u884c\u66ab\u505c0.5\u79d2\uff0c\u7b2c6\u884c\u986f\u793a\u60b2\u50b7\u7684\u81c9\uff0c\u7b2c7\u884c\u518d\u6b21\u66ab\u505c0.5\u79d2\u3002<\/p>\n\n\n\n<p>\u9019\u500b\u7a0b\u5f0f\u5728\u5beb\u5165micro:bit\u4e4b\u5f8c\uff0c\u5c31\u6703\u4e0d\u65b7\u5730\u5728\u5169\u500b\u4e0d\u540c\u7684\u8868\u60c5\u4e4b\u9593\u9032\u884c\u8b8a\u63db\uff0c\u6bcf0.5\u79d2\u8b8a\u5316\u4e00\u6b21\u5594\u3002<\/p>\n\n\n\n<p>\u6240\u6709\u53ef\u4ee5\u4f7f\u7528\u7684\u9810\u8a2d\u5716\u50cf\u756b\u9762\uff0c\u53ef\u4ee5\u5728<a href=\"https:\/\/microbit-micropython.readthedocs.io\/en\/v1.0.1\/tutorials\/images.html\">\u8aaa\u660e\u6587\u4ef6<\/a>\u4e2d\u627e\u5230\u5594\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"yi-chuan-lie-he-hui-quan-de-ji-qiao-lai-bian-huan-biao-qing\">\u4ee5\u4e32\u5217\u548c\u8ff4\u5708\u7684\u6280\u5de7\u4f86\u8b8a\u63db\u8868\u60c5<a href=\"#yi-chuan-lie-he-hui-quan-de-ji-qiao-lai-bian-huan-biao-qing\"><\/a><\/h2>\n\n\n\n<p>\u5982 \u679c\u6211\u5011\u6709\u8a31\u591a\u7684\u5716\u50cf\u9700\u8981\u4f9d\u5e8f\u5448\u73fe\uff08\u4f8b\u5982\u8981\u88fd\u4f5c\u52d5\u756b\u7684\u6642\u5019\uff09\uff0c\u90a3\u9ebc\u5c31\u9700\u8981\u4f7f\u7528\u4e00\u500b\u4e32\u5217\u653e\u7f6e\u6240\u6709\u8981\u4f9d\u5e8f\u986f\u793a\u7684\u5716\u50cf\uff0c\u6700\u5f8c\u518d\u5229\u7528\u4e00\u500b\u8ff4\u5708\u4f86\u4f9d\u5e8f\u986f\u793a\u4e32\u5217\u8cc7\u6599\u4e2d\u7684\u5167\u5bb9\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\nimages = &#91;Image.ARROW_E, Image.ARROW_S, Image.ARROW_W, Image.ARROW_N]\r\nwhile True:\r\n    for img in images:\r\n        display.show(img)\r\n        sleep(500)<\/code><\/pre>\n\n\n\n<p>\u82e5\u662f\u8981\u52a0\u5165\u66f4\u591a\u7684\u5716\u50cf\uff0c\u53ef\u4ee5\u5728images\u8b8a\u6578\u4e4b\u5f8c\u52a0\u4e0a\u66f4\u591a\u7684\u5716\u50cf\uff0c\u52a0\u5165\u7684\u65b9\u6cd5\u5c31\u5982\u5e95\u4e0b\u7684\u7a0b\u5f0f\u4e2d\u7684\u7b2c4\u884c\uff0c\u4ee5+=\u904b\u7b97\u5b50\u628a\u53e6\u4e00\u500b\u4e32\u5217\u52a0\u5230\u539f\u6709\u7684\u4e32\u5217\u4e2d\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\nimages = &#91;Image.ARROW_E, Image.ARROW_SE, Image.ARROW_S, Image.ARROW_SW]\r\nimages += &#91;Image.ARROW_W, Image.ARROW_NW, Image.ARROW_N, Image.ARROW_NE]\r\nwhile True:\r\n    for img in images:\r\n        display.show(img)\r\n        sleep(300)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"yu-she-de-tu-an-chuan-lie-allarrows-yi-ji-allclocks\">\u9810\u8a2d\u7684\u5716\u6848\u4e32\u5217ALL_ARROWS\u4ee5\u53caALL_CLOCKS<a href=\"#yu-she-de-tu-an-chuan-lie-allarrows-yi-ji-allclocks\"><\/a><\/h2>\n\n\n\n<p>\u4e0d\u904e\uff0c\u5176\u5be6\u6709\u4e00\u500b\u9810\u8a2d\u7684\u4e32\u5217ALL_ARROWS\u7528\u4f86\u653e\u7f6e\u6240\u6709\u7684\u7bad\u982d\u7b26\u865f\uff0c\u4e5f\u5c31\u662f\u5b83\u7684\u5167\u5bb9\u5c31\u662f\u4e0a\u9762\u9019\u500b\u7a0b\u5f0f\u4e2d\u7684images\u5f8c\u4f86\u7684\u5167\u5bb9\uff0c\u5229\u7528\u9019\u500b\u4e32\u5217\uff0c\u540c\u6a23\u7684\u7bad\u982d\u52d5\u756b\u7a0b\u5f0f\u53ef\u4ee5\u7c21\u5316\u6210\u5982\u4e0b\u6240\u793a\u7684\u6a23\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\n\nwhile True:\n    for arrow in Image.ALL_ARROWS:\n        display.show(arrow)\n        sleep(200)<\/code><\/pre>\n\n\n\n<p>\u4e0d\u904e\uff0c\u5c0d\u65bc\u653e\u5728\u540c\u4e00\u500b\u4e32\u5217\u4e2d\u7684\u5716\u6848\u800c\u8a00\uff0cdisplay\u51fd\u6578\u8eab\u5c31\u652f\u63f4\u52d5\u756b\u986f\u793a\u7684\u529f\u80fd\uff0c\u4e0a\u8ff0\u7684\u7a0b\u5f0f\u5176\u5be6\u53ef\u4ee5\u7528\u4e00\u884c\u6307\u4ee4\u5c31\u53ef\u4ee5\u5b8c\u6210\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import * \r\n\r\ndisplay.show(Image.ALL_ARROWS, loop=True, delay=300)<\/code><\/pre>\n\n\n\n<p>\u9664\u4e86\u7bad\u982d\u7684\u7b26\u865f\u4e4b\u5916\uff0c\u6240\u6709\u7684\u6307\u91dd\u7b26\u865f\u4e5f\u6709\uff0c\u5b83\u662fALL_CLOCKS\uff0c\u4fee\u6539\u5f8c\u7684\u7a0b\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rom microbit import *\r\n\r\nwhile True:\r\n    for arrow in Image.ALL_CLOCKS:\r\n        display.show(arrow)\r\n        sleep(5000)<\/code><\/pre>\n\n\n\n<p>\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\u6211\u5011\u628a\u5207\u63db\u7684\u6642\u9593\u8a2d\u5b9a\u70ba5\u79d2\uff0c\u5982\u6b64\u6307\u91dd\u8f49\u52d5\u4e00\u5708\u4e4b\u5f8c\u525b\u597d\u5c31\u662f1\u5206\u9418\u3002\u540c\u6a23\u7684\uff0c\u4e0a\u8ff0\u7684\u7a0b\u5f0f\u529f\u80fd\u4e5f\u53ef\u4ee5\u5229\u7528\u4e00\u884c\u4f86\u5b8c\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import * \r\n\r\ndisplay.show(Image.ALL_CLOCKS, loop=True, delay=5000)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"zi-ding-tu-an-ji-dong-hua\">\u81ea\u8a02\u5716\u6848\u53ca\u52d5\u756b<a href=\"#zi-ding-tu-an-ji-dong-hua\"><\/a><\/h2>\n\n\n\n<p>\u9664\u4e86\u4f7f\u7528\u539f\u6709\u7684\u5716\u6848\u4e4b\u5916\uff0c\u6211\u5011\u4e5f\u53ef\u4ee5\u5728micro:bit\u4e2d\u5efa\u7acb\u81ea\u5df1\u7684\u5716\u6848\uff0c\u4e26\u900f\u904e\u9019\u4e9b\u5716\u6848\u5efa\u7acb\u4e00\u4e9b\u81ea\u8a02\u52d5\u756b\u3002\u5efa\u7acb\u5716\u6848\u7684\u985e\u5225\u662fImage\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import * \r\n\r\nairplane = Image('00900:00900:09990:90909:00900')\r\ndisplay.show(airplane)<\/code><\/pre>\n\n\n\n<p>\u5728\u7a0b\u5f0f\u7b2c3\u884c\u7684\u5730\u65b9\uff0c\u4f7f\u7528Image\u985e\u5225\u7684\u521d\u59cb\u5316\u529f\u80fd\uff0c\u50b3\u5165\u5982\u4e0a\u6240\u793a\u4e4b\u683c\u5f0f\u7684\u5b57\u4e32\uff0c\u5c31\u53ef\u4ee5\u5efa\u7acb\u81ea\u8a02\u5716\u6848\uff0c\u5f97\u5230\u7684airplane\u9019\u500b\u8b8a\u6578\u5373\u53ef\u5229\u7528display.show()\u986f\u793a\u51fa\u4f86\u3002\u9084\u8a18\u5f97micro:bit\u5171\u670925\u9846LED\u55ce\uff1f\u4e0a\u8ff0\u7684\u6bcf\u4e00\u500b\u6578\u5b57\u5206\u5225\u4ee3\u8868\u8a72\u4f4d\u7f6e\u7684LED\u7684\u4eae\u5ea6\uff0c9\u662f\u6700\u4eae\uff0c0\u5c31\u662f\u95dc\u9589\u3002\u4e0d\u904e\uff0c\u4e0a\u9762\u7684\u5beb\u6cd5\u4e26\u4e0d\u5bb9\u6613\u770b\u5f97\u51fa\u4f86\u5716\u6848\u7684\u6a23\u5f0f\uff0c\u56e0\u6b64\u5927\u90e8\u4efd\u7684\u60c5\u5f62\u4e0b\u6211\u5011\u628a\u5b83\u5beb\u6210\u4ee5\u4e0b\u7684\u6a23\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import * \r\n\r\nairplane = Image(\r\n    '00900:'\r\n    '00900:'\r\n    '09990:'\r\n    '90909:'\r\n    '00900')\r\ndisplay.show(airplane)<\/code><\/pre>\n\n\n\n<p>\u8acb\u7559\u610f\uff0c\u4ee5\u4e0a\u7684\u5beb\u6cd5\u53ea\u662f\u628a\u4e00\u500b\u539f\u672c\u653e\u5728\u540c\u4e00\u884c\u7684\u5b57\u4e32\u5206\u6210\u4e0d\u540c\u884c\u4f86\u986f\u793a\uff0c\u5728\u7b2c4\u884c\u5230\u7b2c7\u884c\u5f8c\u9762\u90fd\u6c92\u6709\u9017\u865f\u5594\u3002<\/p>\n\n\n\n<p>\u6709\u4e86\u4ee5\u4e0a\u81ea\u8a02\u5716\u6848\u7684\u529f\u80fd\u4e4b\u5f8c\uff0c\u6211\u5011\u5c31\u53ef\u4ee5\u628a\u81ea\u8a02\u7684\u52d5\u756b\u7684\u6bcf\u4e00\u683c\u5716\u6848\u90fd\u8a2d\u8a08\u597d\u4ea4\u7531\u7a0b\u5f0f\u5e6b\u6211\u5011\u5c55\u793a\u51fa\u4f86\uff0c\u540c\u5b78\u5011\u53ef\u4ee5\u57f7\u884c\u4e0b\u9762\u9019\u500b\u4f8b\u5b50\uff0c\u57f7\u884c\u770b\u770b\u6703\u770b\u5230\u4ec0\u9ebc\u52d5\u756b\u5594\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import * \r\n\r\nairplane = list()\r\nairplane.append(Image(\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00900'))\r\nairplane.append(Image(\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00900:'\r\n    '00900'))\r\nairplane.append(Image(\r\n    '00000:'\r\n    '00000:'\r\n    '00900:'\r\n    '00900:'\r\n    '09990'))\r\nairplane.append(Image(\r\n    '00000:'\r\n    '00900:'\r\n    '00900:'\r\n    '09990:'\r\n    '90909'))\r\nairplane.append(Image(\r\n    '00900:'\r\n    '00900:'\r\n    '09990:'\r\n    '90909:'\r\n    '00900'))\r\nairplane.append(Image(\r\n    '00900:'\r\n    '09990:'\r\n    '90909:'\r\n    '00900:'\r\n    '00000:')) \r\nairplane.append(Image(\r\n    '09990:'\r\n    '90909:'\r\n    '00900:'\r\n    '00000:'\r\n    '00000:')) \r\nairplane.append(Image(\r\n    '90909:'\r\n    '00900:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'))\r\nairplane.append(Image(\r\n    '00900:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'))\r\nairplane.append(Image(\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'\r\n    '00000:'))\r\n\r\ndisplay.show(airplane, delay=100, loop=True)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"huo-yong-invert-han-shu\">\u6d3b\u7528invert()\u51fd\u6578<a href=\"#huo-yong-invert-han-shu\"><\/a><\/h2>\n\n\n\n<p>Image\u7684iinvert()\u51fd\u6578\u53ef\u4ee5\u8b93\u76ee\u524d\u7684\u5716\u6848\u5167\u5bb9\u9032\u884c\u53cd\u76f8\u986f\u793a\uff0c\u5982\u679c\u6211\u5011\u60f3\u8981\u8b93\u67d0\u4e00\u500b\u5716\u6848\u53cd\u76f8\u986f\u793a\uff0c\u53ea\u8981\u91dd\u5c0d\u8a72\u5716\u6848\u4f7f\u7528invert\u51fd\u6578\u5c31\u53ef\u4ee5\uff0c\u8acb\u770b\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\nimage = Image.HAPPY\r\nwhile True:\r\n    display.show(image)\r\n    sleep(200)\r\n    display.show(image.invert())\r\n    sleep(200)<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u7684\u7a0b\u5f0f\u53ef\u4ee5\u8b93\u7b11\u81c9\u7684\u5716\u6848\u4ee50.2\u79d2\u70ba\u9593\u9694\u6301\u7e8c\u4e0d\u65b7\u5730\u9583\u720d\u3002\u900f\u904e\u4e00\u500b\u8ff4\u5708\uff0c\u6211\u5011\u4e5f\u53ef\u4ee5\u88fd\u4f5c\u51fa\u7531\u6697\u800c\u4eae\u7684LED\u5716\u6848\uff0c\u8b93\u5229\u7528\u5faa\u74b0\u52d5\u756b\u4f86\u64ad\u653e\uff0c\u7a0b\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\nimages = &#91;Image().invert()*(i\/9) for i in range(10)]\r\nwhile True:\r\n    display.show(images, delay=50, loop=False)\r\n    display.show(reversed(images), delay=50, loop=False)<\/code><\/pre>\n\n\n\n<p>\u57f7\u884c\u4e0a\u9762\u7684\u7a0b\u5f0f\uff0c\u540c\u5b78\u5011\u53ef\u4ee5\u770b\u5230micro:bit\u768425\u9846LED\u540c\u6642\u7531\u6697\u5230\u4eae \uff0c\u518d\u7531\u4eae\u8b8a\u5316\u5230\u6697\u7684\u52d5\u614b\u6548\u679c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"shi-yong-image-han-shu-zhi-zuo-ping-yi-dong-hua\">\u4f7f\u7528Image\u51fd\u6578\u88fd\u4f5c\u5e73\u79fb\u52d5\u756b<a href=\"#shi-yong-image-han-shu-zhi-zuo-ping-yi-dong-hua\"><\/a><\/h2>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u4e2d\u5b9a\u7fa9\u4e86\u5e7e\u500b\u4e0d\u540c\u7684\u5716\u6848\u4f9d\u5e8f\u8f2a\u6d41\u986f\u793a\u4ee5\u5efa\u7acb\u52d5\u756b\uff0c\u4f46\u662f\uff0c\u6709\u4e9b\u60c5\u5f62\u7684\u52d5\u756b\u662f\u5c6c\u65bc\u79fb\u52d5\u5716\u6848\u578b\u7684\uff0c\u4f8b\u5982\u628a\u4e00\u500b\u7269\u4ef6\u5f80\u4e0a\u4e0b\u5de6\u53f3\u56db\u500b\u65b9\u5411\u7684\u5176\u4e2d\u4e00\u500b\u65b9\u5411\u4f86\u79fb\u52d5\u7684\u9019\u7a2e\u52d5\u756b\uff0c\u9084\u53ef\u4ee5\u5229\u7528Image\u6240\u63d0\u4f9b\u7684\u65b9\u6cd5\u51fd\u6578\u4f86\u5b8c\u6210\u3002\u5728REPL\u74b0\u5883\u4e2d\uff0c\u5982\u679c\u4ee5dir(Image)\u4f86\u67e5\u8a62Image\u4e2d\u6240\u6709\u652f\u63f4\u7684\u51fd\u6578\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u6240\u793a\u7684\u986f\u793a\u5167\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;'width', 'height', 'get_pixel', 'set_pixel', 'shift_left', 'shift_right', 'shift_up', \r\n'shift_down', 'copy', 'crop', 'invert', 'fill', 'blit', \r\n'HEART', 'HEART_SMALL', 'HAPPY', 'SMILE', 'SAD', 'CONFUSED', \r\n'ANGRY', 'ASLEEP', 'SURPRISED', 'SILLY', 'FABULOUS', 'MEH', \r\n'YES', 'NO', 'CLOCK12', 'CLOCK1', 'CLOCK2', 'CLOCK3', 'CLOCK4', \r\n'CLOCK5', 'CLOCK6', 'CLOCK7', 'CLOCK8', 'CLOCK9', 'CLOCK10', 'CLOCK11', \r\n'ARROW_N', 'ARROW_NE', 'ARROW_E', 'ARROW_SE', 'ARROW_S', 'ARROW_SW', \r\n'ARROW_W', 'ARROW_NW', 'TRIANGLE', 'TRIANGLE_LEFT', 'CHESSBOARD', \r\n'DIAMOND', 'DIAMOND_SMALL', 'SQUARE', 'SQUARE_SMALL', 'RABBIT', 'COW', \r\n'MUSIC_CROTCHET', 'MUSIC_QUAVER', 'MUSIC_QUAVERS', 'PITCHFORK', 'XMAS',\r\n'PACMAN', 'TARGET', 'ALL_CLOCKS', 'ALL_ARROWS', 'TSHIRT', 'ROLLERSKATE', \r\n'DUCK', 'HOUSE', 'TORTOISE', 'BUTTERFLY', 'STICKFIGURE', 'GHOST', 'SWORD', \r\n'GIRAFFE', 'SKULL', 'UMBRELLA', 'SNAKE']<\/code><\/pre>\n\n\n\n<p>\u5728\u9019\u4e9b\u5167\u5bb9\u4e2d\uff0c\u6240\u6709\u5927\u5beb\u7684\u9805\u76ee\u90fd\u662f\u9810\u8a2d\u7684\u5716\u6848\u540d\u7a31\uff0c\u800c\u5c0f\u5beb\u7684\u90e8\u4efd\u5c31\u662f\u652f\u63f4\u7684\u51fd\u6578\u3002\u5176\u4e2d\uff0cshift_right\u3001shift_up\u7b49\u56db\u500b\u51fd\u6578\u5206\u5225\u5c31\u662f\u91dd\u5c0dImage\u7684\u5167\u5bb9\u505a\u56db\u500b\u65b9\u5411\u5e73\u79fb\u7684\u64cd\u4f5c\uff0c\u900f\u904e\u9019\u5e7e\u500b\u51fd\u6578\u7684\u61c9\u7528\uff0c\u5c31\u53ef\u4ee5\u8f15\u6613\u5730\u88fd\u4f5c\u5e73\u79fb\u5f0f\u7684\u52d5\u756b\u6548\u679c\uff0c\u8acb\u770b\u4ee5\u4e0b\u9019\u500b\u7a0b\u5f0f\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\nimport random\r\n             \r\nwhile True:\r\n    track = Image(\r\n                  '00000:'\r\n                  '00000:'\r\n                  '00000:'\r\n                  '00000:'\r\n                  '00900:'\r\n                  '00900:'\r\n                  '09990:'\r\n                  '90909:'\r\n                  '00900:'\r\n                  '09990:'\r\n                  '00000')\r\n    for i in range(11):\r\n        display.show(track.shift_up(i))\r\n        sleep(150)<\/code><\/pre>\n\n\n\n<p>\u540c\u6a23\u90fd\u662f\u4e00\u67b6\u98db\u6a5f\u5411\u4e0a\u98db\u904e\u7684\u52d5\u756b\uff0c\u9019\u500b\u7a0b\u5f0f\u770b\u8d77\u4f86\u662f\u5426\u6bd4\u8f03\u7c21\u55ae\u4e00\u4e9b\u5462\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"xian-shi-juan-dong-wen-zi\">\u986f\u793a\u6372\u52d5\u6587\u5b57<a href=\"#xian-shi-juan-dong-wen-zi\"><\/a><\/h2>\n\n\n\n<p>\u96d6\u7136micro:bit\u53ea\u6709\u4e00\u500b5&#215;5\u7684\u9ede\u77e9\u9663LED\uff0c\u4f46\u662f\u986f\u793a\u6587\u5b57\u4e5f\u96e3\u4e0d\u5012\u5b83\uff0c\u53ea\u8981\u4f7f\u7528display.scroll\u6307\u4ee4\u5c31\u53ef\u4ee5\u4e86\u3002\u4ee5\u4e0b\u662f\u986f\u793a\u6587\u5b57\u7684\u7c21\u6613\u7a0b\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\ndisplay.scroll('Hello')<\/code><\/pre>\n\n\n\n<p>\u7531\u65bc\u5b83\u53ea\u6709\u4e00\u884c\u6307\u4ee4\u6c92\u6709\u4efb\u4f55\u7684\u8ff4\u5708\uff0c\u56e0\u6b64\u9019\u500bHello\u6587\u5b57\u8a0a\u606f\u53ea\u6703\u6372\u52d5\u4e00\u6b21\uff0c\u63a5\u8457\u5c31\u6c92\u6709\u4efb\u4f55\u756b\u9762\u4e86\uff0c\u5982\u679c\u60f3\u8981\u518d\u770b\u4e00\u6b21\u8a0a\u606f\uff0c\u53ef\u4ee5\u6309\u4e0bmicro:bit\u80cc\u9762\u7684\u91cd\u7f6e\u6309\u9215\uff08\u5728USB\u9023\u63a5\u5668\u65c1\u908a\uff09\u3002<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7684\u8ff4\u5708\u6307\u4ee4\u8b93\u9019\u4e9b\u8a0a\u606f\u4e00\u76f4\u4e0d\u65b7\u5730\u6372\u52d5\u64ad\u653e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from microbit import *\r\n\r\nwhile True:\r\n    display.scroll('Hello!')\r\n    display.scroll('Richard')<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>micro:bit\u53ef\u4ee5\u5229\u7528Python\u4f86\u7de8\u5beb\u5728\u677f\u5b50\u4e0a\u57f7\u884c\u7684\u7a0b\u5f0f\uff0c\u4f46\u662f\u4e26\u4e0d\u662f\u5b8c\u6574\u7684Python\u7a0b\u5f0f\uff0c\u800c\u662fPython\u7a0b\u5f0f\u7684\u5b50\u96c6\u5408\uff0c\u4e00\u500b\u53eb\u505aMicroPython\u7684\u76f4\u8b6f\u5668\u3002\u7279\u5225\u8981\u7559\u610f\u7684\u662f\uff0c\u56e0\u70ba\u6709\u8a31\u591a\u4e0d\u540c\u7684\u958b\u767c\u677f\uff0c\u5305\u62ecESP32\u3001Pico W\u3001HaloCode\u7b49\u7b49\u4e5f\u90fd\u6709\u652f\u63f4MicroPython\uff0c\u4f46\u662f\u5b83\u5011\u4f7f\u7528\u7684\u662f\u4e0d\u540c\u7684\u76f4\u8b6f\u5668\uff0c\u8a9e\u6cd5\u4ee5\u53ca\u64cd\u4f5c\u65b9\u5f0f\u4e5f\u6709\u4e00\u4e9b\u4e0d\u540c\uff0c\u6240\u4ee5\u5728MicroPython\u7684\u76f8\u95dc\u6587\u4ef6\u4e4b\u524d\uff0c\u4e00\u5b9a\u8981\u78ba\u5b9a\u9019\u4efd\u6587\u4ef6\u6240\u9069\u7528\u7684\u958b\u767c\u677f\uff0c\u624d\u53ef\u4ee5\u9806\u5229\u5730\u57f7\u884c\u5594\u3002<\/p>\n","protected":false},"author":1,"featured_media":2480,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,15],"tags":[],"class_list":["post-2478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microbit","category-python"],"jetpack_featured_media_url":"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/oqtafyt5ktw.jpg","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2478","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=2478"}],"version-history":[{"count":1,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2478\/revisions"}],"predecessor-version":[{"id":2479,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2478\/revisions\/2479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media\/2480"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}