{"id":1474,"date":"2022-05-16T15:30:48","date_gmt":"2022-05-16T07:30:48","guid":{"rendered":"https:\/\/104.es\/?p=1474"},"modified":"2022-05-16T15:30:48","modified_gmt":"2022-05-16T07:30:48","slug":"nodemcu-max7219","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2022\/05\/16\/nodemcu-max7219\/","title":{"rendered":"NodeMCU + Max7219"},"content":{"rendered":"\n<p>NodeMCU\u672c\u8eab\u4e26\u6c92\u6709\u81ea\u5e36\u986f\u793a\u5668\uff0c\u9664\u4e86\u628a\u5f9e\u611f\u6e2c\u5668\u53d6\u5f97\u7684\u8cc7\u6599\u900f\u904e\u7db2\u969b\u7db2\u8def\u50b3\u905e\u5230\u5916\u754c\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u9023\u63a5\u4e00\u4e9b\u5e38\u898b\u7684\u986f\u793a\u5668\u4ee5\u986f\u793a\u51fa\u5b57\u5143\u8cc7\u8a0a\u6216\u662f\u6578\u503c\u8cc7\u6599\uff0c\u6bcf\u4e00\u7a2e\u986f\u793a\u88dd\u7f6e\u5404\u6709\u5176\u7279\u8272\uff0c\u672c\u6b21\u6240\u4f7f\u7528\u7684Max7219\u662f\u4e00\u500b\u6bd4\u8f03\u5927\u578b\u76848&#215;8\u9ede\u9663\u5b57\u5143\u8f38\u51fa\u88dd\u7f6e\uff0c\u9664\u4e86\u986f\u793a\u6578\u5b57\u4e4b\u5916\u4e5f\u53ef\u4ee5\u986f\u793a\u5927\u5c0f\u5beb\u6587\u5b57\u53ca\u5404\u7a2e\u5b57\u5143\u7b26\u865f\u3002\u4ee5\u4e0b\u662fmax7219\u7684\u5916\u89c0\uff08\u4ee5\u4e0b\u662f\u75314\u500b8&#215;8\u9ede\u9663\u5f0fLED\u6240\u7d44\u6210\u7684\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-2.png?w=800\" alt=\"\" class=\"wp-image-1478\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-2.png 800w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-2-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-2-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>\u96d6\u7136\u770b\u8d77\u4f86\u6709\u975e\u5e38\u591a\u7684LED\uff0c\u4f46\u662f\u5176\u4e2d\u5927\u90e8\u4efd\u7684\u5de5\u4f5c\u90fd\u5df2\u88ab\u88e1\u9762\u7684IC\u5e6b\u6211\u5011\u5b8c\u6210\u4e86\uff0c\u56e0\u6b64\uff0c\u5176\u5be6\u5b83\u53ea\u6709\u5c11\u5c11\u76845\u689d\u7dda\u9700\u8981\u9023\u63a5\u3002\u80cc\u9762\u770b\u8d77\u4f86\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-3.png?w=800\" alt=\"\" class=\"wp-image-1480\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-3.png 800w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-3-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-3-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>\u5176\u4e2d\uff0cVCC\u548cGND\u4e0d\u7528\u8aaa\uff0c\u7576\u7136\u5c31\u662f\u5206\u5225\u63a5\u52305V\u96fb\u6e90\u548c\u63a5\u5730\uff0c\u6211\u5011\u76f4\u63a5\u628a\u5b83\u5011\u63a5\u5230NodeMCU\u7684\u63a7\u5145\u677f\u6240\u63d0\u4f9b\u7684USB\u96fb\u6e90\u8655\u3002\u53e6\u5916\u7684\u4e09\u689d\u7dda\uff0cDIN\uff0cCS\uff0c\u4ee5\u53caCLK\uff0c\u5247\u5206\u5225\u63a5\u5230D7\uff0cD8\uff0c\u548cD5\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-4.png?w=800\" alt=\"\" class=\"wp-image-1482\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-4.png 800w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-4-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-4-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>\u9019\u6a23\u5c31\u9023\u63a5\u597d\u56c9\u3002\u5728\u7a0b\u5f0f\u65b9\u9762\uff0c\u5b83\u9700\u8981\u4e00\u500b\u9a45\u52d5\u7a0b\u5f0fmax7219\uff0c\u9019\u5f88\u5bb9\u6613\uff0c\u53ea\u8981\u524d\u5f80\u4ee5\u4e0b\u7684\u7db2\u5740\uff0c\u628a\u9019\u500b\u6a94\u6848\u5229\u7528ampy\u4e0a\u50b3\u5230\u677f\u5b50\u4e0a\u5c31\u53ef\u4ee5\u4e86\uff0c\u9664\u4e86\u4f7f\u7528ampy\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u5728Mu Editor\u4e0a\u7684File\u6a94\u6848\u7ba1\u7406\u4e0a\u50b3\u5230\u677f\u5b50\u88e1\u9762\u3002<\/p>\n\n\n\n<p>https:\/\/github.com\/mcauser\/micropython-max7219<\/p>\n\n\n\n<p>\u6211\u5011\u9700\u8981\u7684\u662f\u4e0a\u9762\u9019\u500b\u7db2\u9801\u4e2d\u7684max7219.py\u9019\u500b\u6a94\u6848\uff0c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"264\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-5.png?w=992\" alt=\"\" class=\"wp-image-1484\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-5.png 992w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-5-300x80.png 300w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-5-768x204.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/figure>\n\n\n\n<p>\u5728Mu Editor\u7684\u6a94\u6848\u7ba1\u7406\u4e0a\u770b\u8d77\u4f86\u50cf\u662f\u4ee5\u4e0b\u9019\u500b\u6a23\u5b50\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-6.png?w=540\" alt=\"\" class=\"wp-image-1486\" width=\"308\" height=\"146\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-6.png 540w, https:\/\/104.es\/wp-content\/uploads\/2022\/05\/image-6-300x142.png 300w\" sizes=\"auto, (max-width: 308px) 100vw, 308px\" \/><\/figure>\n\n\n\n<p>\u7d50\u5408\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\u53d6\u5f97DHT11\u6eab\u6fd5\u5ea6\u611f\u6e2c\u5668\u7684\u65b9\u6cd5\uff0c\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\u53ef\u4ee5\u5b9a\u671f\u7684\u8b93\u9019\u500b\u986f\u793a\u5668\u986f\u793a\u51fa\u73fe\u5728\u7684\u6eab\u5ea6\u4ee5\u53ca\u6fd5\u5ea6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from machine import Pin, SPI\nimport max7219\nimport time, dht\nd = dht.DHT11(Pin(16))\nspi = SPI(1, baudrate=10000000, polarity=0, phase=0)\ndisp = max7219.Matrix8x8(spi, Pin(15), 4)\ndisp.brightness(1)\nwhile True:\n    d.measure()\n    disp.fill(0)\n    disp.text(\"{}c\".format(d.temperature()), 0, 0, 1)\n    disp.show()\n    time.sleep(1)\n    disp.fill(0)\n    disp.text(\"{}%\".format(d.humidity()), 0, 0, 1)\n    disp.show()\n    time.sleep(2)\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u7a0b\u5f0f\u7684\u57f7\u884c\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"NodeMCU + max7219 + DHT11\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/XXuXp2mNzwE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u9664\u4e86\u5373\u6642\u986f\u793a\u6eab\u6fd5\u5ea6\u4e4b\u5916\uff0c\u6709\u6642\u5019\u6211\u5011\u4e5f\u6703\u5229\u7528\u9019\u500b\u986f\u793a\u5668\u4f86\u986f\u793a\u6587\u5b57\uff0c\u4f46\u56e0\u70ba\u5b83\u4e00\u6b21\u53ea\u80fd\u986f\u793a4\u500b\u5b57\u5143\uff0c\u6240\u4ee5\u6211\u5011\u9700\u8981\u5229\u7528\u4e00\u4e9b\u7c21\u55ae\u7684\u5b57\u4e32\u8655\u7406\u6280\u5de7\u4f86\u8b93\u8a0a\u606f\u5167\u5bb9\u4ee5\u6372\u52d5\u7684\u65b9\u5f0f\u4f86\u986f\u793a\u51fa\u6240\u6709\u7684\u5b57\u5143\u7684\u5167\u5bb9\uff0c\u7a0b\u5f0f\u78bc\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from machine import Pin, SPI\nimport max7219\nimport time\nspi = SPI(1, baudrate=10000000, polarity=0, phase=0)\ndisp = max7219.Matrix8x8(spi, Pin(15), 4)\ndisp.brightness(1)\nmsg = \"We love Python!   \"\nwhile True:\n    disp.fill(0)\n    disp.text(msg&#091;:4], 0, 0, 1)\n    disp.show()\n    time.sleep(1)\n    msg = msg&#091;1:] + msg&#091;0]<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8ff0\u7a0b\u5f0f\u7684\u57f7\u884c\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"NodeMCU max7219\u6372\u52d5\u5b57\u4e32\u986f\u793a\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/apybvpqayI4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u4ee5\u4e0b\u7a0b\u5f0f\u7d50\u5408\u4e86\u7db2\u8def\u6821\u6642\u4ee5\u53ca\u6642\u9593\u3002\u6eab\u6fd5\u5ea6\u986f\u793a\u7684\u529f\u80fd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from machine import Pin, SPI\nimport max7219\nimport time, network, dht\nfrom ntptime import settime\nspi = SPI(1, baudrate=10000000, polarity=0, phase=0)\ndisp = max7219.Matrix8x8(spi, Pin(15), 4)\ndisp.brightness(0)\ndef show_message(s):\n    disp.fill(0)\n    disp.text(s, 0, 0, 1)\n    disp.show()\n    time.sleep(1)\n\nd = dht.DHT11(Pin(16))\nwlan = network.WLAN(network.STA_IF)\nwlan.connect(\"ssid\", \"password\")\nshow_message(\"-&gt;&lt;-\")\nwhile not wlan.isconnected():\n    pass\nshow_message(\"ok\")\nsettime()\nwhile True:\n    utc = time.mktime(time.localtime())\n    data = time.localtime(utc+28800)\n    show_message(str(data&#091;0]))\n    show_message(\"{:&gt;2d}{:&gt;2d}\".format(data&#091;1], data&#091;2]))\n    show_message(\"{:&gt;2d}{:&gt;2d}\".format(data&#091;3], data&#091;4]))\n    d.measure()\n    show_message(\"{}c\".format(d.temperature()))\n    show_message(\"{}%\".format(d.humidity()))\n<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528\u4e0a\u8ff0\u7684\u7a0b\u5f0f\u78bc\u5225\u5fd8\u4e86\u8981\u4fee\u6539ssid\u548cpassword\u624d\u80fd\u5920\u6b63\u5e38\u904b\u4f5c\u3002\u4ee5\u4e0b\u662f\u57f7\u884c\u7684\u7d50\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"NodeMCU + max7219 + ntptime\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/Z78-uEdZ5pE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>NodeMCU\u672c\u8eab\u4e26\u6c92\u6709\u81ea\u5e36\u986f\u793a\u5668\uff0c\u9664\u4e86\u628a\u5f9e\u611f\u6e2c\u5668\u53d6\u5f97\u7684\u8cc7\u6599\u900f\u904e\u7db2\u969b\u7db2\u8def\u50b3\u905e\u5230\u5916\u754c\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u9023\u63a5\u4e00\u4e9b\u5e38\u898b\u7684\u986f\u793a\u5668\u4ee5\u986f\u793a\u51fa\u5b57\u5143\u8cc7\u8a0a\u6216\u662f\u6578\u503c\u8cc7\u6599\uff0c\u6bcf\u4e00\u7a2e\u986f\u793a\u88dd\u7f6e\u5404\u6709\u5176\u7279\u8272\uff0c\u672c\u6b21\u6240\u4f7f\u7528\u7684Max7219\u662f\u4e00\u500b\u6bd4\u8f03\u5927\u578b\u76848&#215;8\u9ede\u9663\u5b57\u5143\u8f38\u51fa\u88dd\u7f6e\uff0c\u9664\u4e86\u986f\u793a\u6578\u5b57\u4e4b\u5916\u4e5f\u53ef\u4ee5\u986f\u793a\u5927\u5c0f\u5beb\u6587\u5b57\u53ca\u5404\u7a2e\u5b57\u5143\u7b26\u865f\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":[13,15],"tags":[43,44],"class_list":["post-1474","post","type-post","status-publish","format-standard","hentry","category-nodemcu","category-python","tag-max7219","tag-micropython"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1474","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=1474"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1474\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=1474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=1474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=1474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}