{"id":2813,"date":"2018-09-16T16:26:34","date_gmt":"2018-09-16T08:26:34","guid":{"rendered":"https:\/\/drho.club\/?p=2357"},"modified":"2018-09-16T16:26:34","modified_gmt":"2018-09-16T08:26:34","slug":"nodemcu-micropython-rgb-led","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2018\/09\/16\/nodemcu-micropython-rgb-led\/","title":{"rendered":"\u3010NodeMCU MicroPython\u3011\u4e09\u8272LED\u7c21\u6613\u61c9\u7528"},"content":{"rendered":"<p>\u4e09\u8272LED\u6a21\u7d44\u662f\u4e00\u500b\u975e\u5e38\u597d\u73a9\uff0c\u4e5f\u5f88\u5bb9\u6613\u4e0a\u624b\u7684LED\u6a21\u7d44\uff0c\u4f7f\u7528\u540c\u4e00\u9846LED\uff0c\u900f\u904eRGB\u4e09\u500b\u4e0d\u540c\u63a5\u8173\u7d66\u5b9a\u4e0d\u540c\u7684\u6578\u503c\uff0c\u5c31\u53ef\u4ee5\u7d44\u5408\u51fa\u975e\u5e38\u591a\u7a2e\u984f\u8272\uff0c\u5341\u5206\u6709\u8da3\u3002\u5728\u9019\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c31\u4f86\u6559\u540c\u5b78\u5011\u5982\u4f55\u4f7f\u7528NodeMCU\u7684MicroPython\u7a0b\u5f0f\u78bc\uff0c\u8b93\u4e09\u8272LED\u7522\u751f\u51fa\u6709\u8da3\u7684\u6548\u679c\u3002<\/p>\n<p>\u5728\u9019\u4e00\u500b\u55ae\u5143\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u7684\u4e09\u8272LED\u6a21\u7d44\u5982\u4e0b\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-15.58.26.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2354\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-15.58.26.jpg\" alt=\"\" width=\"368\" height=\"479\" \/><\/a><\/p>\n<p>\u7531\u65bc\u5b83\u5df2\u7d93\u88ab\u52a0\u4e0a\u9650\u6d41\u96fb\u963b\u4e86\uff0c\u6240\u4ee5\u6211\u5011\u53ef\u4ee5\u653e\u5fc3\u5730\u76f4\u63a5\u9001\u4fe1\u865f\u7d66\u5b83\u3002\u5982\u4e0a\u5716\u6240\u793a\uff0c\u6a21\u7d44\u4e0b\u65b9\u6709\u56db\u652f\u63a5\u8173\uff0c\u6700\u53f3\u908a\u90a3\u652f\u63a5\u8173\u662f\u8981\u9023\u63a5\u5230\u5730\u7ddaGND\u7528\u7684\uff0c\u53e6\u5916\u4e09\u652f\u9867\u540d\u601d\u7fa9\uff0c\u5fda\u5011\u4e0a\u9762\u90fd\u6709\u6a19\u8a18\uff0c\u5206\u5225\u662f\u8981\u50b3\u9001\u7d66\u5b83\u7684\u85cd\u8272\u3001\u7da0\u8272\u3001\u4ee5\u53ca\u7d05\u8272\u6578\u503c\uff0c\u6578\u503c\u7684\u5927\u5c0f\u4ee3\u8868\u984f\u8272\u7684\u5f37\u5f31\u3002\u4e00\u958b\u59cb\uff0c\u6211\u5011\u53ea\u662f\u5148\u4ee5\u6578\u4f4d\u8f38\u51fa\u7684\u65b9\u5f0f\uff0c\u5229\u75281\u548c0\u4f86\u6c7a\u5b9a\u6700\u5927\u503c\u9084\u662f\u6c92\u6709\u4efb\u4f55\u503c\uff0c\u5982\u6b64\u53ef\u4ee5\u7d44\u5408\u51fa\u57fa\u672c\u7684\u984f\u8272\u3002\u4e0d\u904e\uff0c\u5728\u9019\u88e1\u6211\u5011\u5148\u53ea\u793a\u7bc43\u500b\u57fa\u672c\u984f\u8272\u5c31\u597d\u3002<\/p>\n<p>\u5728\u96fb\u8def\u9023\u63a5\u7684\u90e8\u4efd\uff0c\u5982\u4e0b\u5716\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-16.08.38.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2355 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-16.08.38.jpg\" alt=\"\" width=\"800\" height=\"599\" \/><\/a><\/p>\n<p>\u70ba\u4e86\u65b9\u4fbf\u56fa\u5b9a\uff0c\u6211\u5011\u628a\u5b83\u63d2\u5230\u9eb5\u5305\u677f\u4e0a\uff0c\u5176\u5be6\u540c\u5b78\u5011\u4e5f\u53ef\u4ee5\u76f4\u63a5\u9023\u63a5\u96fb\u8def\u5373\u53ef\u3002\u53e6\u5916\u4e00\u9762\u6211\u5011\u5f9eD1\u958b\u59cb\u9023\u63a5\uff0c\u5206\u5225\u628aD1\u63a5\u5230R\uff0cD2\u63a5\u5230G\uff0cD3\u63a5\u5230B\uff0c\u5982\u4e0b\u5716\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-16.08.50.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2356 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2018\/09\/2018-09-16-16.08.50.jpg\" alt=\"\" width=\"800\" height=\"622\" \/><\/a><\/p>\n<p>\u56de\u5230NodeMCU\u7684\u63a5\u8173\u5716\u770b\u4e00\u4e0b\uff0c\u53ef\u4ee5\u77e5\u9053\uff0cD1\u5c0d\u61c9\u5230GPIO5\uff0cD2\u5c0d\u61c9\u5230DPIO4\uff0c\u800cD3\u5c0d\u61c9\u5230GPIO0\uff0c\u6240\u4ee5\u7a0b\u5f0f\u78bc\u5c31\u53ef\u4ee5\u8a2d\u8a08\u5982\u4e0b\uff1a<\/p>\n<p>[code language=&#8221;python&#8221;]<br \/>\nfrom machine import Pin<br \/>\nimport time<\/p>\n<p>ledR = Pin(5, Pin.OUT)<br \/>\nledG = Pin(4, Pin.OUT)<br \/>\nledB = Pin(0, Pin.OUT)<\/p>\n<p>def turn(r, g, b):<br \/>\n    ledR.value(r)<br \/>\n    ledG.value(g)<br \/>\n    ledB.value(b)<\/p>\n<p>while True:<br \/>\n    turn(1, 0, 0)<br \/>\n    time.sleep(0.5)<br \/>\n    turn(0, 1, 0)<br \/>\n    time.sleep(0.5)<br \/>\n    turn(0, 0, 1)<br \/>\n    time.sleep(0.5)<\/p>\n<p>[\/code]<\/p>\n<p>\u5728\u9019\u500b\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u8a2d\u8a08\u4e86\u4e00\u500b\u51fd\u6578turn\uff0c\u65b9\u4fbf\u6211\u5011\u4e00\u6b21\u8a2d\u5b9a3\u500b\u63a5\u8173\u7684\u8f38\u51fa\uff0c0\u8868\u793a\u6c92\u6709\u8f38\u51fa\uff0c\u800c1\u8868\u793a\u6700\u5927\u503c\u8f38\u51fa\u3002\u5982\u6b64\uff0c\u9019\u500b\u7a0b\u5f0f\u5728\u958b\u59cb\u57f7\u884c\u4e4b\u5f8c\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u4e09\u8272LED\u5206\u5225\u4f9d\u4e09\u500b\u984f\u8272\u8f2a\u6d41\u986f\u793a\u3002\u57f7\u884c\u7684\u7bc4\u4f8b\u5982\u4e0b\u9762\u7684\u5f71\u7247\u6240\u793a\uff1a<\/p>\n<p><iframe loading=\"lazy\" title=\"\u4f7f\u7528NodeMCU\u9a45\u52d5\u4e09\u8272LED\u7bc4\u4f8b\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/g0mSgqwx0O4?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><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e09\u8272LED\u6a21\u7d44\u662f\u4e00\u500b\u975e\u5e38\u597d\u73a9\uff0c\u4e5f\u5f88\u5bb9\u6613\u4e0a\u624b\u7684LED\u6a21\u7d44\uff0c\u4f7f\u7528\u540c\u4e00\u9846LED\uff0c\u900f\u904eRGB\u4e09\u500b\u4e0d\u540c\u63a5\u8173\u7d66\u5b9a\u4e0d\u540c\u7684\u6578\u503c\uff0c\u5c31\u53ef\u4ee5\u7d44\u5408\u51fa\u975e\u5e38\u591a\u7a2e\u984f\u8272\uff0c\u5341\u5206\u6709\u8da3\u3002\u5728\u9019\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c31\u4f86\u6559\u540c\u5b78\u5011\u5982\u4f55\u4f7f\u7528NodeMCU\u7684MicroPython\u7a0b\u5f0f\u78bc\uff0c\u8b93\u4e09\u8272LED\u7522\u751f\u51fa\u6709\u8da3\u7684\u6548\u679c\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],"tags":[44,48,198],"class_list":["post-2813","post","type-post","status-publish","format-standard","hentry","category-nodemcu","tag-micropython","tag-nodemcu","tag-led"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2813","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=2813"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2813\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}