{"id":1807,"date":"2017-12-24T13:38:51","date_gmt":"2017-12-24T05:38:51","guid":{"rendered":"https:\/\/drho.club\/?p=1807"},"modified":"2017-12-24T13:38:51","modified_gmt":"2017-12-24T05:38:51","slug":"arduino-unit-3","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2017\/12\/24\/arduino-unit-3\/","title":{"rendered":"[Arduino\u521d\u968e\u5be6\u7fd2] Unit 3\uff1aRGB 3\u8272LED\u5be6\u7fd2"},"content":{"rendered":"<p>\u7531\u65bcArduino\u975e\u5e38\u53d7\u5230\u6b61\u8fce\uff0c\u56e0\u6b64\u6709\u8a31\u591a\u91dd\u5c0dArduino\u8a2d\u8a08\u7684\u8f38\u51fa\u5165\u6a21\u7d44\u5c31\u61c9\u904b\u800c\u751f\uff0c\u9019\u4e9b\u6a21\u7d44\u7684\u7279\u8272\u5c31\u662f\u6703\u70ba\u4e00\u4e9b\u5143\u4ef6\u5efa\u7acb\u5c08\u5c6c\u7684\u9023\u63a5\u96fb\u8def\uff0c\u4f7f\u5176\u5728\u9023\u63a5\u5230Arduino\u6642\u4e0d\u9700\u8981\u518d\u52a0\u4e0a\u5176\u5b83\u7684\u96f6\u4ef6\uff0c\u53ea\u8981\u63a5\u4e0a\u5373\u53ef\u4f7f\u7528\u3002\u672c\u55ae\u5143\u5be6\u7fd2\u4e2d\u6240\u4f7f\u7528\u7684RGB 3\u8272LED\u6a21\u7d44\u5c31\u662f\u5176\u4e2d\u7684\u500b\u5e38\u7528\u7684\u6a21\u7d44\uff0c\u5b83\u57283\u8272LED\u4e0a\u76f4\u63a5\u52a0\u4e0a\u9650\u6d41\u96fb\u963b\uff0c\u8b93\u6211\u5011\u5728\u4f7f\u7528\u7684\u6642\u5019\uff0c\u53ea\u8981\u76f4\u63a5\u628a\u5404\u500b\u63a5\u8173\u9023\u63a5\u5230\u677f\u5b50\u4e0a\u7684\u6578\u4f4d\u8f38\u51fa\u63a5\u8173\u5373\u53ef\u3002\u4ee5\u4e0b\u662f\u96fb\u8def\u5716\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24_12-27-44.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1811\" src=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24_12-27-44.png\" alt=\"\" width=\"393\" height=\"585\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24_12-27-44.png 393w, https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24_12-27-44-202x300.png 202w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/a><\/p>\n<p>\u8981\u518d\u4e00\u6b21\u5f37\u8abf\u7684\u662f\uff0c\u4e0a\u5716\u4e2d\u6240\u4f7f\u7528\u7684\u5143\u4ef6\u6211\u5011\u5047\u8a2d\u662f\u4f7f\u7528Arduino\u5c08\u7528\u76843\u8272LED\u6a21\u7d44\uff0c\u5982\u679c\u4f60\u7528\u7684\u662f\u4e00\u822c\u76843\u8272LED\uff08\u6c92\u6709\u9644\u5c0f\u5c0f\u7684\u96fb\u8def\u677f\u7684\u8a71\uff09\uff0c\u4e00\u5b9a\u8981\u5982\u4e0a\u4e00\u500b\u55ae\u5143\u5be6\u7fd2\u4e2d\u6240\u793a\u7684\u4e00\u6a23\uff0c\u81ea\u884c\u52a0\u4e0a\u61c9\u7528\u7684\u9650\u6d41\u96fb\u963b\u624d\u884c\u3002\u6b64\u5916\uff0c\u5728\u4e0a\u5716\u4e2d\uff0c\u6211\u5011\u9023\u63a5\u5230Arduino\u677f\u5b50\u4e0aGND\u63a5\u8173\u90a3\u500b3\u8272LED\u91dd\u8173\u4e0a\u9762\u9700\u8981\u6a19\u793a\u7684\u662f\u300c-\u300d\u6216\u65e6\u300cGND\u300d\u624d\u884c\uff0c\u5176\u5b83\u76843\u652f\u63a5\u8173\u5373\u5206\u5225\u4ee3\u8868RGB\u4e09\u500b\u984f\u8272\u3002\u5728\u4e0a\u5716\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u5011\u5206\u5225\u628a\u5b83\u5011\u63a5\u5230\u6578\u4f4d\u6578\u51fa\u5165\u76842\u30013\u30014\u7b49\u4e09\u652f\u63a5\u8173\u3002\u6211\u5011\u4f7f\u7528\u76843\u8272LED\u6a21\u7d44\u5982\u4e0b\u5716\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.24.41.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1812\" src=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.24.41.jpg\" alt=\"\" width=\"485\" height=\"287\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.24.41.jpg 485w, https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.24.41-300x178.jpg 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/a><\/p>\n<p>\u9023\u63a5\u5b8c\u6210\u7684\u96fb\u8def\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1813 aligncenter\" src=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21.jpg\" alt=\"\" width=\"800\" height=\"450\" srcset=\"https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21.jpg 800w, https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21-300x169.jpg 300w, https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21-768x432.jpg 768w, https:\/\/104.es\/wp-content\/uploads\/2017\/12\/2017-12-24-12.26.21-600x338.jpg 600w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>\u786c\u9ad4\u7dda\u8def\u63a5\u597d\u4e4b\u5f8c\uff0c\u5c31\u53ef\u4ee5\u900f\u904e\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\u8f2a\u6d41\u9ede\u4eae3\u500b\u984f\u8272\uff1a<\/p>\n<p>[code]<br \/>\nint LEDRpin = 2;<br \/>\nint LEDGpin = 3;<br \/>\nint LEDBpin = 4;<br \/>\nvoid setup() {<br \/>\n  pinMode(LEDRpin, OUTPUT);<br \/>\n  pinMode(LEDGpin, OUTPUT);<br \/>\n  pinMode(LEDBpin, OUTPUT);<br \/>\n  digitalWrite(LEDRpin, LOW);<br \/>\n  digitalWrite(LEDGpin, LOW);<br \/>\n  digitalWrite(LEDBpin, LOW);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\n  digitalWrite(LEDRpin, HIGH);<br \/>\n  digitalWrite(LEDGpin, LOW);<br \/>\n  digitalWrite(LEDBpin, LOW);<br \/>\n  delay(500);<br \/>\n  digitalWrite(LEDRpin, LOW);<br \/>\n  digitalWrite(LEDGpin, HIGH);<br \/>\n  digitalWrite(LEDBpin, LOW);<br \/>\n  delay(500);<br \/>\n  digitalWrite(LEDRpin, LOW);<br \/>\n  digitalWrite(LEDGpin, LOW);<br \/>\n  digitalWrite(LEDBpin, HIGH);<br \/>\n  delay(500);<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>\u57f7\u884c\u7684\u7d50\u679c\uff0c\u5982\u4e0b\u9762\u7684\u5f71\u7247\u6240\u793a\u7684\u6a23\u5b50\uff1a<\/p>\n<p><iframe loading=\"lazy\" title=\"RGD LED\u71c8\u4eae\u8f2a\u6d41\u986f\u793a3\u7a2e\u4e0d\u540c\u7684\u984f\u8272\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/AQQqyMRLLmA?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>\u7136\u800c\uff0c\u6b63\u5982\u4f60\u6240\u60f3\u7684\uff0cRGB\u53ea\u662f\u4e09\u7a2e\u539f\u8272\uff0c\u5be6\u969b\u4e0a\u6b64\u9846LED\u53ef\u4ee5\u986f\u793a\u7684\u984f\u8272\u662f\u53ef\u4ee5\u6df7\u642d\u7684\uff0c\u4e5f\u5c31\u662f3\u500b\u63a5\u8173\u5982\u679c\u90fd\u662fHIGH\u7684\u8a71\uff0c\u90a3\u5c31\u6703\u8b8a\u6210\u767d\u8272\uff0c\u5982\u679cRG\u662fHIGH\u800cB\u662fLOW\u7684\u8a71\uff0c\u5247\u662f\u9ec3\u8272\uff0c\u4f9d\u6b64\u985e\u63a8\u3002\u70ba\u4e86\u65b9\u4fbf\u5728\u7a0b\u5f0f\u4e2d\u8abf\u6574\u984f\u8272\uff0c\u6211\u5011\u53ef\u4ee5\u628a\u7a0b\u5f0f\u6539\u4e00\u4e0b\uff0c\u52a0\u4e0a\u4e00\u500b\u5c08\u9580\u8f38\u51fa\u7684\u51fd\u6578turn\uff0c\u7136\u5f8c\u900f\u904e\u8a72\u51fd\u6578\u4f86\u81ea\u7531\u5730\u958b\u555f\u6216\u662f\u95dc\u9589\u5176\u4e2d\u7684\u984f\u8272\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>[code]<br \/>\nint LEDRpin = 2;<br \/>\nint LEDGpin = 3;<br \/>\nint LEDBpin = 4;<\/p>\n<p>void turn(int r, int g, int b) {<br \/>\n  digitalWrite(LEDRpin, r);<br \/>\n  digitalWrite(LEDGpin, g);<br \/>\n  digitalWrite(LEDBpin, b);<br \/>\n}<\/p>\n<p>void setup() {<br \/>\n  pinMode(LEDRpin, OUTPUT);<br \/>\n  pinMode(LEDGpin, OUTPUT);<br \/>\n  pinMode(LEDBpin, OUTPUT);<br \/>\n  turn(LOW, LOW, LOW);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\n  turn(HIGH, LOW, LOW);  delay(500);<br \/>\n  turn(LOW, HIGH, LOW);  delay(500);<br \/>\n  turn(LOW, LOW, HIGH);  delay(500);<br \/>\n  turn(HIGH, HIGH, LOW);  delay(500);<br \/>\n  turn(LOW, HIGH, HIGH);  delay(500);<br \/>\n  turn(HIGH, HIGH, HIGH);  delay(500);<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>\u652f\u63f4\u66f4\u591a\u984f\u8272\u57f7\u884c\u7bc4\u4f8b\u5f71\u7247\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><iframe loading=\"lazy\" title=\"RGB LED \u6a21\u7d44\u8b8a\u63db\u5404\u7a2e\u984f\u8272\u7684\u793a\u7bc4\u5f71\u7247\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/aoYHT3Z7Zy0?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>\u7531\u65bcArduino\u975e\u5e38\u53d7\u5230\u6b61\u8fce\uff0c\u56e0\u6b64\u6709\u8a31\u591a\u91dd\u5c0dArduino\u8a2d\u8a08\u7684\u8f38\u51fa\u5165\u6a21\u7d44\u5c31\u61c9\u904b\u800c\u751f\uff0c\u9019\u4e9b\u6a21\u7d44\u7684\u7279\u8272\u5c31\u662f\u6703\u70ba\u4e00\u4e9b\u5143\u4ef6\u5efa\u7acb\u5c08\u5c6c\u7684\u9023\u63a5\u96fb\u8def\uff0c\u4f7f\u5176\u5728\u9023\u63a5\u5230Arduino\u6642\u4e0d\u9700\u8981\u518d\u52a0\u4e0a\u5176\u5b83\u7684\u96f6\u4ef6\uff0c\u53ea\u8981\u63a5\u4e0a\u5373\u53ef\u4f7f\u7528\u3002\u672c\u55ae\u5143\u5be6\u7fd2\u4e2d\u6240\u4f7f\u7528\u7684RGB 3\u8272LED\u6a21\u7d44\u5c31\u662f\u5176\u4e2d\u7684\u500b\u5e38\u7528\u7684\u6a21\u7d44\uff0c\u5b83\u57283\u8272LED\u4e0a\u76f4\u63a5\u52a0\u4e0a\u9650\u6d41\u96fb\u963b\uff0c\u8b93\u6211\u5011\u5728\u4f7f\u7528\u7684\u6642\u5019\uff0c\u53ea\u8981\u76f4\u63a5\u628a\u5404\u500b\u63a5\u8173\u9023\u63a5\u5230\u677f\u5b50\u4e0a\u7684\u6578\u4f4d\u8f38\u51fa\u63a5\u8173\u5373\u53ef\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":[3],"tags":[],"class_list":["post-1807","post","type-post","status-publish","format-standard","hentry","category-arduino"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1807","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=1807"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1807\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=1807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=1807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=1807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}