{"id":2835,"date":"2023-08-06T17:22:02","date_gmt":"2023-08-06T09:22:02","guid":{"rendered":"https:\/\/104.es\/?p=2835"},"modified":"2023-08-06T17:22:03","modified_gmt":"2023-08-06T09:22:03","slug":"nodemcu-led-matrix-max7219","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2023\/08\/06\/nodemcu-led-matrix-max7219\/","title":{"rendered":"\u3010NodeMCU\u3011\u9ede\u9663\u5f0fLED\u63a7\u5236"},"content":{"rendered":"\n<p>LED\u9664\u4e86\u55ae\u7368\u4e00\u9846\u4e00\u9846\u4e4b\u5916\uff0c\u4e5f\u6709\u6392\u6210\u77e9\u9663\u65b9\u5f0f\u7684\u4ee5\u65b9\u4fbf\u6211\u5011\u986f\u793a\u6578\u5b57\u548c\u6587\u5b57\uff0c\u5728\u9019\u500b\u55ae\u5143\u4e2d\u6211\u5011\u5c31\u4f86\u770b\u770b\u5982\u4f55\u9a45\u52d5\u9019\u4e00\u985e\u7684LED\u77e9\u9663\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u4f86\u770b\u770b\u9019\u7a2e\u6a19\u6e96\u578b\u76848&#215;8\u9ede\u9663\u5f0fLED\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-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23.png\" alt=\"\" class=\"wp-image-2836\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23.png 800w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23-768x576.png 768w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23-600x450.png 600w\" 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-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-24.png\" alt=\"\" class=\"wp-image-2837\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-24.png 800w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-24-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-24-768x576.png 768w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-24-600x450.png 600w\" 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-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-25.png\" alt=\"\" class=\"wp-image-2838\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-25.png 800w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-25-300x225.png 300w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-25-768x576.png 768w, https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-25-600x450.png 600w\" 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\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/mcauser\/micropython-max7219\">https:\/\/github.com\/mcauser\/micropython-max7219<\/a><\/p>\n\n\n\n<p>\u4e0a\u50b3\u5b8c\u6210\u4e4b\u5f8c\uff0c\u53ea\u8981\u7de8\u5beb\u4ee5\u4e0b\u7684\u7a0b\u5f0f\uff0c\u5c31\u53ef\u4ee5\u9806\u5229\u5730\u5728LED\u77e9\u9663\u4e0a\u986f\u793a\u51fa\u6587\u5b57\u6216\u6578\u5b57\u56c9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import max7219\r\nimport time\r\nmessages = &#91;'Nice', ' to ', 'meet', 'you!']\r\nfrom machine import Pin, SPI\r\nspi = SPI(1, baudrate=10000000, polarity=0, phase=0)\r\ndisp = max7219.Matrix8x8(spi, Pin(15), 4)\r\ndisp.brightness(0)\r\nwhile True:\r\n\tfor item in messages:\r\n\t\tdisp.fill(0)    \r\n\t\tdisp.text(item,0,0,1)    \r\n\t\tdisp.show()    \r\n\t\ttime.sleep(1)<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u7a0b\u5f0f\u57f7\u884c\u7684\u793a\u7bc4\u5f71\u7247\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\u9a45\u52d54\u500b8x8\u9ede\u77e9\u9663LED\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/xwud32Q0kLA?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>\u7d50\u5408\u4e86WiFi\u7db2\u8def\u9023\u7dda\u8207NTP\u7db2\u8def\u5c0d\u6642\uff0c\u4ee5\u53ca\u6eab\u6fd5\u5ea6\u611f\u6e2c\u5668\u7684\u529f\u80fd\uff0c\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u5c31\u53ef\u4ee5\u88fd\u4f5c\u4e00\u500b\u6eab\u6fd5\u5ea6\u8a08\u6642\u9418\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import max7219\r\nimport time\r\nimport dht\r\nfrom ntptime import settime\r\nfrom machine import Pin, SPI\r\n\r\nsettime()\r\nd = dht.DHT11(Pin(16))\r\nspi = SPI(1, baudrate=10000000, polarity=0, phase=0)\r\ndisp = max7219.Matrix8x8(spi, Pin(15), 4)\r\ndisp.brightness(0)\r\nwhile True:\r\n\tmessages = list()\r\n\tutc = time.mktime(time.localtime())\r\n\tyear, month, day, hour, minute, second, week, days = time.localtime(utc+28800)\r\n\tmessages.append(str(year))\r\n\tmessages.append(\"{:2d}{:2d}\".format(month, day))\r\n\tmessages.append(\"{:2d}{:2d}\".format(hour, minute))\r\n\tfor item in messages:\r\n\t\tdisp.fill(0)    \r\n\t\tdisp.text(item,0,0,1)    \r\n\t\tdisp.show()    \r\n\t\ttime.sleep(2)\r\n\td.measure()\r\n\tdisp.fill(0)\r\n\tdisp.text('{}C'.format(d.temperature()), 0, 0, 1)\r\n\tdisp.show()\r\n\ttime.sleep(2)\r\n\tdisp.fill(0)\r\n\tdisp.text('{}%'.format(d.humidity()), 0, 0, 1)\r\n\tdisp.show()\r\n\ttime.sleep(2)<\/code><\/pre>\n\n\n\n<p>\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 4\u500b8x8LED\u793a\u7bc4\u7a0b\u5f0f\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/NfpZeVGgki0?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>\u8acb\u6ce8\u610f\uff0c\u9019\u500b\u7a0b\u5f0f\u9700\u8981\u5728boot.py\u5efa\u7acb\u4e86\u7db2\u8def\u9023\u7dda\u4e4b\u5f8c\u624d\u80fd\u6b63\u5e38\u904b\u4f5c\u5594\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LED\u9664\u4e86\u55ae\u7368\u4e00\u9846\u4e00\u9846\u4e4b\u5916\uff0c\u4e5f\u6709\u6392\u6210\u77e9\u9663\u65b9\u5f0f\u7684\u4ee5\u65b9\u4fbf\u6211\u5011\u986f\u793a\u6578\u5b57\u548c\u6587\u5b57\uff0c\u5728\u9019\u500b\u55ae\u5143\u4e2d\u6211\u5011\u5c31\u4f86\u770b\u770b\u5982\u4f55\u9a45\u52d5\u9019\u4e00\u985e\u7684LED\u77e9\u9663\u3002<\/p>\n","protected":false},"author":1,"featured_media":2836,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,15],"tags":[],"class_list":["post-2835","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nodemcu","category-python"],"jetpack_featured_media_url":"https:\/\/104.es\/wp-content\/uploads\/2023\/08\/image-23.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2835","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=2835"}],"version-history":[{"count":1,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2835\/revisions"}],"predecessor-version":[{"id":2839,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2835\/revisions\/2839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media\/2836"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}