{"id":18110,"date":"2022-02-24T00:00:25","date_gmt":"2022-02-23T16:00:25","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=18110"},"modified":"2022-02-23T11:04:55","modified_gmt":"2022-02-23T03:04:55","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e5%ae%b6%e5%b1%85%e7%85%a7%e6%98%8e%e7%b3%bb%e7%bb%9f%e4%b8%ad%e6%b7%bb%e5%8a%a0rgb-led%e7%81%af%e5%b8%a6","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/arduino\/how-to-add-an-rgb-led-strip-to-your-home-lighting","title":{"rendered":"\u5982\u4f55\u5728\u5bb6\u5c45\u7167\u660e\u7cfb\u7edf\u4e2d\u6dfb\u52a0RGB LED\u706f\u5e26"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e<a href=\"https:\/\/www.deviceplus.com\/\">DevicePlus.com<\/a>\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002<\/p>\n<p>\u4f7f\u7528LED\u662f\u4e00\u79cd\u4e3a\u5bb6\u5ead\u589e\u6dfb\u8272\u5f69\u7684\u5feb\u6377\u7b80\u5355\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06LED\u706f\u5e26\u5e94\u7528\u4e8e\u53a8\u623f\u50a8\u7269\u67dc\u3001\u5ba2\u5385\u89d2\u843d\u6216\u8005\u4efb\u4f55\u53ef\u80fd\u9700\u8981\u989d\u5916\u7167\u660e\u7684\u5730\u65b9\u3002\u5982\u679c\u60a8\u60f3\u8981\u4ee5\u4f4e\u5ec9\u7684\u4ef7\u683c\u5236\u5907\u81ea\u5df1\u7684\u7167\u660e\u8bbe\u5907\uff0c\u5e76\u4e14\u5bf9\u7167\u660e\u8bbe\u5907\u7684\u989c\u8272\u548c\u56fe\u6848\u8fdb\u884c\u66f4\u591a\u63a7\u5236\u64cd\u4f5c\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528Arduino\u6765\u5b9e\u73b0\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10022\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1.jpg\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1.jpg 960w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1-300x200.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1-768x512.jpg 768w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1-219x146.jpg 219w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1-50x33.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led1-113x75.jpg 113w\" alt=\"\" width=\"960\" height=\"640\" \/><\/p>\n<h3>LED\u706f\u5e26\u5de5\u4f5c\u539f\u7406<\/h3>\n<p>LED\u706f\u5e26\u6709\u591a\u79cd\u5f62\u5f0f\uff0c\u4f46\u662f\u4e00\u822c\u6765\u8bf4\uff0c\u5927\u591a\u6570\u578b\u53f7\u662f\u4e00\u79cd\u653e\u7f6e\u6709\u5468\u671f\u6027LED\u6a21\u5757\u7684\u5e26\u72b6\u677f\uff0c\u5e76\u4e14\u67d0\u4e9b\u6a21\u5757\u4e4b\u95f4\u8fd8\u6709\u865a\u7ebf\u90e8\u5206\uff0c\u5982\u679c\u9700\u8981\uff0c\u60a8\u53ef\u4ee5\u5728\u8fd9\u4e9b\u865a\u7ebf\u7684\u5730\u65b9\u5bf9\u706f\u5e26\u8fdb\u884c\u5207\u5272\u3002\u8fd9\u4e9b\u4f4d\u7f6e\u901a\u5e38\u4f1a\u6807\u6709\u91d1\u5c5e\u89e6\u70b9\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u6dfb\u52a0\u989d\u5916\u7684\u7535\u8def\u4ee5\u5c06\u591a\u4e2a\u706f\u5e26\u8fde\u63a5\u5728\u4e00\u8d77\u3002\u5728\u7aef\u53e3\u60a8\u4f1a\u770b\u5230\u6709\u4e00\u4e9b\u53ef\u4ee5\u63d2\u5165Arduino\u7684\u7535\u7ebf\u3002<br \/>\n\u7535\u7ebf\u7684\u6570\u91cf\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\uff0c\u4f46\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u4f1a\u4f7f\u7528\u5305\u542b\u63a7\u5236\u81ea\u8eab\u7535\u8def\u7684\u706f\u5e26\uff0c\u8ba9\u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4e00\u6839\u7535\u7ebf\u5bf9\u6bcf\u4e2a\u5355\u72ec\u7684LED\u8fdb\u884c\u5bfb\u5740\u3002\u8fd8\u6709\u4e00\u6839\u989d\u5916\u7684\u7535\u6e90\u7ebf\u548c\u5730\u7ebf\uff0c\u8fd9\u610f\u5473\u7740\u6574\u4e2a\u9879\u76ee\u53ea\u9700\u8981\u4e09\u6839\u7535\u7ebf\u5373\u53ef\u3002\u8fd9\u79cd\u7c7b\u578b\u7684\u706f\u5e26\u901a\u5e38\u6765\u8bf4\u90fd\u66f4\u52a0\u65b9\u4fbf\uff0c\u6240\u4ee5\u6211\u4eec\u5c06\u4f1a\u4f7f\u7528\u8be5\u7c7b\u578b\u706f\u5e26\uff0c\u5177\u4f53\u4f7f\u7528\u7684\u578b\u53f7\u4e3a<a href=\"https:\/\/cdn-shop.adafruit.com\/datasheets\/WS2812B.pdf\">\u57fa\u4e8eWS2812B\u7684LED\u706f\u5e26<\/a>\u3002<\/p>\n<p>LED\u706f\u5e26\u53ef\u4ee5\u4f7f\u7528\u5916\u90e8\u5e93\u8fdb\u884c\u63a7\u5236\uff0c\u4f8b\u5982FastLED \u6216\u8005<a href=\"https:\/\/github.com\/adafruit\/Adafruit_NeoPixel\">Adafruit\u7684Neopixel <\/a>\u5e93\u3002\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528FastLED\u5e93\uff0c\u8fd9\u4e2a\u5e93\u5305\u542b\u4e86\u7528\u4e8e\u63a7\u5236\u5404\u79cdLED\u706f\u5e26\u63a7\u5236\u5668\u7684\u51fd\u6570\uff0c\u4ece\u800c\u4f7f\u8bbe\u7f6e\u989c\u8272\u6216\u52a8\u6001\u6a21\u5f0f\u53d8\u5f97\u66f4\u5bb9\u6613\u3002<\/p>\n<p>\u8bf7<a href=\"https:\/\/github.com\/FastLED\/FastLED\/archive\/master.zip\">\u4e0b\u8f7d\u6b64\u94fe\u63a5\u4e2d\u7684\u5e93<\/a>\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u60a8\u7684\u8349\u56fe\u4e2d\u3002\u7136\u540e\uff0c\u5728\u60a8\u7684Arduino IDE\u4e2d\uff0c\u8fdb\u5165<strong>Sketch &gt; Include library &gt; Add .ZIP library<\/strong>\uff0c\u5e76\u9009\u62e9FastLED\u5e93\u3002\u5728File\uff08\u6587\u4ef6\uff09\u83dc\u5355\u7684Example\uff08\u793a\u4f8b\uff09\u90e8\u5206\u8fd8\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u793a\u4f8b\u8349\u56fe\uff0c\u60a8\u53ef\u4ee5\u5728\u63a2\u7d22\u65f6\u67e5\u770b\u8fd9\u4e9b\u793a\u4f8b\u3002\u4e0d\u8fc7\u73b0\u5728\uff0c\u6211\u4eec\u4ece\u4e00\u4e2a\u7b80\u5355\u7684\u5de5\u4f5c\u4f5c\u4e3a\u5f00\u59cb\u2014\u5c06\u6bcf\u4e2aLED\u8bbe\u7f6e\u4e3a\u76f8\u540c\u7684\u989c\u8272\u3002<\/p>\n<h3>\u6240\u9700\u90e8\u4ef6<\/h3>\n<p>\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8d2d\u4e70\u4efb\u610f\u6570\u91cf\u7684LED\u706f\u5e26\u5e03\u7f6e\u5230\u60a8\u7684\u623f\u95f4\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u4e00\u70b9\u662f\uff0c\u6bcf\u4e2aLED\u90fd\u4f1a\u6d88\u8017\u7535\u529b\u3002\u5982\u679c\u4f7f\u7528\u5c11\u91cf\u7684LED\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Arduino\u76845V\u7535\u6e90\uff0c\u4f46\u662f\u5982\u679c\u662f\u5927\u91cfLED\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u5916\u90e8\u7535\u6e90\u3002\u6211\u4eec\u4ec5\u4f7f\u7528Arduino\u6765\u5b8c\u6210\u6b64\u9879\u76ee\uff0c\u4f46\u662f\u5982\u679c\u60a8\u60f3\u8981\u6269\u5c55\u9879\u76ee\u7684\u8bdd\uff0c\u9700\u8981\u6ce8\u610f\u7535\u6e90\u7684\u9009\u62e9\u3002\u57fa\u4e8e\u4ee5\u4e0a\u5185\u5bb9\uff0c\u60a8\u5c06\u9700\u8981\u4ee5\u4e0b\u90e8\u4ef6\uff1a<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/led-strip-lights\/1245482\/\">\u4e00\u4e2aLED\u706f\u5e26<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10023\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2.png 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2-300x169.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2-260x146.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2-50x28.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led2-133x75.png 133w\" alt=\"\" width=\"700\" height=\"394\" \/><\/td>\n<\/tr>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/ac-dc-adapters\/1217130\/\">\u7535\u6e90\uff08\u7528\u4e8e\u5927\u706f\u5e26\uff09<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10024\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3.png 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3-300x169.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3-260x146.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3-50x28.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led3-133x75.png 133w\" alt=\"\" width=\"700\" height=\"394\" \/><\/td>\n<\/tr>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/arduino\/7154081\/\">Arduino Uno<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10025\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4.png 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4-300x169.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4-260x146.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4-50x28.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led4-133x75.png 133w\" alt=\"\" width=\"700\" height=\"394\" \/><\/td>\n<\/tr>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/arduino\/7154084\/\">Arduino IDE<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10026\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5-300x169.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5-260x146.jpg 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5-50x28.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led5-133x75.jpg 133w\" alt=\"\" width=\"700\" height=\"394\" \/><\/td>\n<\/tr>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/usb-cables\/8950499\/\">USB\u6570\u636e\u7ebf<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10027\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6.png\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6.png 600w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6-300x168.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6-260x146.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6-50x28.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led6-134x75.png 134w\" alt=\"\" width=\"600\" height=\"336\" \/><\/td>\n<\/tr>\n<tr>\n<td width=\"216\"><a href=\"https:\/\/uk.rs-online.com\/web\/p\/breadboard-jumper-wire-kits\/7916454\/\">\u7535\u7ebf<\/a><\/td>\n<td width=\"240\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10028\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7.png 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7-300x169.png 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7-260x146.png 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7-50x28.png 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led7-133x75.png 133w\" alt=\"\" width=\"700\" height=\"394\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2a\u9879\u76ee\u7684\u63a5\u7ebf\u76f8\u5bf9\u7b80\u5355\uff0c\u56e0\u4e3a\u6211\u4eec\u9009\u62e9\u4e86\u53ef\u5bfb\u5740\u7684LED\u706f\u5e26\u3002\u4f46\u5728\u63a5\u7ebf\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u5c06\u8981\u4f7f\u7528\u7684\u4ee3\u7801\u3002<\/p>\n<h3>\u4ee3\u7801<\/h3>\n<p>\u7531\u4e8e\u6211\u4eec\u4f7f\u7528\u7684\u662fFastLED\u5e93\uff0c\u6240\u4ee5\u793a\u4f8b\u6240\u7528\u7684\u4ee3\u7801\u975e\u5e38\u7b80\u5355\u3002\u6211\u4eec\u5c06\u6307\u793aArduino\u6309\u7167\u987a\u5e8f\u6253\u5f00\u6bcf\u4e2aLED\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u4e00\u79cd\u989c\u8272\u3002\u4ee5\u4e0b\u4e3a\u5b8c\u6574\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u4e0a\u4f20\u5230Arduino Uno\u3002<\/p>\n<p><span style=\"color: #3366ff;\">#include &lt;FastLED.h&gt;<\/span><\/p>\n<p><span style=\"color: #3366ff;\">#define numberOfLEDs 100<\/span><br \/>\n<span style=\"color: #3366ff;\">#define controlPin 5<\/span><\/p>\n<p><span style=\"color: #3366ff;\">CRGB leds[numberOfLEDs];<\/span><\/p>\n<p><span style=\"color: #3366ff;\">void setup() {<\/span><br \/>\n<span style=\"color: #3366ff;\">FastLED.addLeds&lt;WS2812B, controlPin, GRB&gt;(leds, numberOfLEDs);}<\/span><\/p>\n<p><span style=\"color: #3366ff;\">void loop() {<\/span><br \/>\n<span style=\"color: #3366ff;\">for (int thisLED = 0; thisLED &lt; numberOfLEDs; thisLED++) {<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].r = 50;<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].b = 0;<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].g = 0;<\/span><br \/>\n<span style=\"color: #3366ff;\">FastLED.show();<\/span><br \/>\n<span style=\"color: #3366ff;\">}<\/span><\/p>\n<p><span style=\"color: #3366ff;\">}<\/span><\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8fd9\u4e9b\u4ee3\u7801\u7684\u5185\u5bb9\u3002<\/p>\n<p><span style=\"color: #3366ff;\">#include &lt;FastLED.h&gt;<\/span><\/p>\n<p><span style=\"color: #3366ff;\">#define numberOfLEDs 100<\/span><br \/>\n<span style=\"color: #3366ff;\">#define controlPin 5<\/span><\/p>\n<p><span style=\"color: #3366ff;\">CRGB leds[numberOfLEDs];<\/span><br \/>\n\u7b2c\u4e00\u884c\u7528\u4e8e\u5bfc\u5165FastLED\u5e93\uff0c\u4f7f\u60a8\u53ef\u4ee5\u5728\u8349\u56fe\u4e2d\u4f7f\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002\u63a5\u4e0b\u6765\u7684\u4e24\u884c\u7528\u4e8e\u5b9a\u4e49\u4e00\u5bf9\u5e38\u91cf\uff0c\u8fd9\u4e24\u4e2a\u5e38\u91cf\u5206\u522b\u4e0e\u706f\u5e26\u4e0a\u60a8\u8981\u63a7\u5236\u7684LED\u6570\u91cf\uff08\u5982\u679c\u60a8\u613f\u610f\u7684\u8bdd\u4e5f\u53ef\u4ee5\u53ea\u63a7\u5236\u706f\u5e26\u4e0a\u7684\u4e00\u90e8\u5206LED\uff09\u4ee5\u53ca\u5c06\u7528\u4e8e\u63a7\u5236LED\u7684Arduino\u677f\u4e0a\u7684\u5f15\u811a\u6570\u91cf\u76f8\u5bf9\u5e94\u3002\u6700\u540e\uff0cCRGB\u4e00\u884c\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u4e0a\u9762\u6307\u5b9a\u7684LED\u6570\u91cf\u7684\u9635\u5217\u3002<\/p>\n<p>\u5728\u672c\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u752810\u4e2aLED\uff0c\u8fd9\u4e2a\u6570\u91cf\u5f88\u5c0f\uff0c\u53ea\u7528Arduino\u5c31\u53ef\u4ee5\u63d0\u4f9b\u8db3\u591f\u7684\u7535\u6e90\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u53ea\u7528\u5b83\u6765\u8fdb\u884c\u6f14\u793a\u4e86\u3002<\/p>\n<p><span style=\"color: #3366ff;\">void setup() {<\/span><br \/>\n<span style=\"color: #3366ff;\">FastLED.addLeds&lt;WS2812B, controlPin, GRB&gt;(leds, numberOfLEDs);<\/span><br \/>\n<span style=\"color: #3366ff;\">}<\/span><\/p>\n<p>\u8fd9\u4e00\u884c\u901a\u8fc7\u4f7f\u7528\u4e0eLED\u706f\u5e26\u5bf9\u5e94\u7684\u63a7\u5236\u5668\u82af\u7247\u7ec4\u6765\u5bf9LED\u8fdb\u884c\u8bbe\u7f6e\u3002\u8be5\u884c\u5185\u5bb9\u4f1a\u56e0\u60a8\u6240\u4f7f\u7528\u7684\u706f\u5e26\u578b\u53f7\u800c\u5f02\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u67e5\u770bFastLED\u6587\u6863\u6765\u627e\u5230\u9002\u7528\u7684\u547d\u4ee4\u3002FastLED\u7684Blink\u8349\u56fe\u4e2d\uff08\u4e0d\u540c\u4e8eArduino IDE\u7684\u5185\u7f6eBlink\u8349\u56fe\uff09\u5305\u542b\u4e86\u5bf9\u5e94\u4e8e\u5404\u79cd\u82af\u7247\u7ec4\u7684\u4ee3\u7801\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fWS2812B\uff0c\u90a3\u4e48\u4f7f\u7528\u4e0a\u6587\u4e2d\u7684\u4ee3\u7801\u5373\u53ef\u3002<\/p>\n<p><span style=\"color: #3366ff;\">void loop() {<\/span><br \/>\n<span style=\"color: #3366ff;\">for (int thisLED = 0; thisLED &lt; numberOfLEDs; thisLED++) {<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].r = 50;<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].b = 0;<\/span><br \/>\n<span style=\"color: #3366ff;\">leds[thisLED].g = 0;<\/span><br \/>\n<span style=\"color: #3366ff;\">FastLED.show();<\/span><br \/>\n<span style=\"color: #3366ff;\">}<\/span><\/p>\n<p><span style=\"color: #3366ff;\">}<\/span><\/p>\n<p>\u5728\u672c\u90e8\u5206\u4e2d\uff0c<em>for()<\/em>\u5faa\u73af\u5c06\u904d\u5386\u9635\u5217\u4e2d\u7684\u6bcf\u4e2aLED\u5e76\u5c06\u5176\u4e00\u4e00\u6253\u5f00\u3002\u4ee5<em>leds[]<\/em>\u5f00\u5934\u7684\u4e09\u884c\u901a\u8fc7\u5c06\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u503c\uff08\u6bcf\u4e2a\u503c\u6700\u9ad8255\uff09\u8fdb\u884c\u7ec4\u5408\u6765\u8bbe\u7f6eLED\u989c\u8272\u3002\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u8c03\u6574\u8fd9\u4e9b\u503c\u6765\u66f4\u6539LED\u7684\u989c\u8272\u3002\u5982\u679c\u628a\u4e09\u4e2a\u503c\u90fd\u8bbe\u7f6e\u4e3a0\uff0cLED\u5c06\u4f1a\u5b8c\u5168\u7184\u706d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10029\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8.jpg\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8.jpg 960w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8-300x199.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8-768x510.jpg 768w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8-220x146.jpg 220w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8-50x33.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2021\/01\/led8-113x75.jpg 113w\" alt=\"\" width=\"960\" height=\"637\" \/><\/p>\n<h3>\u63a5\u7ebf<\/h3>\n<p>\u56e0\u4e3a\u6211\u4eec\u9009\u62e9\u4e86\u4e00\u4e2a\u5f88\u7b80\u5355\u7684LED\u706f\u5e26\uff0c\u6240\u4ee5\u63a5\u7ebf\u5de5\u4f5c\u4e5f\u53d8\u5f97\u5f88\u7b80\u5355\u3002\u60a8\u53ea\u9700\u8981\u8fde\u63a5\u4e09\u6839\u7535\u7ebf\u5373\u53ef\uff1a<\/p>\n<p>\u25cf \u5c06LED\u706f\u5e26\u4e0a\u76845V\u7535\u7ebf\u8fde\u63a5\u5230Arduino\u4e0a\u76845V\uff08\u4ec5\u6709\u51e0\u4e2aLED\uff09\u6216\u5916\u90e8\u7535\u6e90\uff08\u6709\u8bb8\u591aLED\uff09\u3002<br \/>\n\u25cf \u5c06LED\u706f\u5e26\u4e0a\u7684GND\u8fde\u63a5\u5230Arduino\u4e0a\u7684GND\u3002<br \/>\n\u25cf \u5c06\u4e2d\u95f4\u7684\u7535\u7ebf\uff08\u6709\u65f6\u6807\u6709DIN\uff09\u8fde\u63a5\u5230Arduino\u4e0a\u76845V\u3002<\/p>\n<p>\u5b8c\u6210\u4e09\u6839\u7535\u7ebf\u7684\u8fde\u63a5\u540e\uff0c\u4e3a\u60a8\u7684Arduino\uff08\u548c\u60a8\u7684LED\u706f\u5e26\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u4e86\u5355\u72ec\u7684\u7535\u6e90\u7684\u8bdd\uff09\u4f9b\u7535\uff0cLED\u706f\u5c06\u4f1a\u88ab\u6253\u5f00\u3002\u5c1d\u8bd5\u8c03\u6574\u4ee3\u7801\u6765\u66f4\u6539\u989c\u8272\u6216\u7f16\u5199\u66f4\u590d\u6742\u7684\u52a8\u6001\u6a21\u5f0f\u3002FastLED\u5e93\u8fd8\u9644\u5e26\u4e00\u4e9b\u9884\u5236\u8349\u56fe\uff0c\u60a8\u53ef\u4ee5\u53c2\u8003\u5b83\u4eec\u5bf9\u66f4\u591a\u5185\u5bb9\u8fdb\u884c\u63a2\u7d22\u3002<\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/micro.wfjydl.com\/deviceplus\/wp-content\/uploads\/2018\/08\/Device-Plus-logo-for-author-info-75x75.png\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\" width=\"64\" height=\"64\" \/><\/div>\n<div class=\"desc-wrapper\">\n<h5>DevicePlus \u7f16\u8f91\u56e2\u961f<\/h5>\n<div class=\"desc\">\n<p>\u8bbe\u5907\u5347\u7ea7\u7248\u9002\u7528\u4e8e\u6240\u6709\u70ed\u7231\u7535\u5b50\u548c\u673a\u7535\u4e00\u4f53\u5316\u7684\u4eba\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8eDevicePlus.com\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002 \u4f7f\u7528LED\u662f\u4e00\u79cd\u4e3a\u5bb6\u5ead\u589e\u6dfb\u8272\u5f69\u7684\u5feb\u6377\u7b80\u5355\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06LED\u706f\u5e26\u5e94\u7528\u4e8e\u53a8\u623f\u50a8\u7269\u67dc\u3001\u5ba2\u5385\u89d2\u843d\u6216\u8005\u4efb\u4f55\u53ef\u80fd\u9700\u8981\u989d\u5916\u7167\u660e\u7684\u5730\u65b9\u3002\u5982\u679c\u60a8\u60f3\u8981\u4ee5\u4f4e\u5ec9\u7684\u4ef7\u683c\u5236\u5907\u81ea\u5df1\u7684\u7167\u660e [&hellip;]","protected":false},"author":4,"featured_media":18111,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1130],"tags":[],"class_list":["post-18110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/18110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/comments?post=18110"}],"version-history":[{"count":6,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/18110\/revisions"}],"predecessor-version":[{"id":18144,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/18110\/revisions\/18144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/18111"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=18110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=18110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=18110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}