{"id":14365,"date":"2023-10-10T15:30:05","date_gmt":"2023-10-10T07:30:05","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=14365"},"modified":"2026-03-28T22:40:01","modified_gmt":"2026-03-28T14:40:01","slug":"led%e7%92%b0%e5%bd%a2%e6%b5%81%e6%b0%b4%e7%87%88","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2023\/10\/led%e7%92%b0%e5%bd%a2%e6%b5%81%e6%b0%b4%e7%87%88\/","title":{"rendered":"LED\u74b0\u5f62\u6d41\u6c34\u71c8"},"content":{"rendered":"<p>\u6587\u7ae0\u53c3\u8003\u81ea\uff1a<a href=\"http:\/\/www.esp32learning.com\/code\/esp32-and-ws2812-rgb-led-ring-example.php\" target=\"_blank\" rel=\"noopener\">ESP32 AND WS2812 RGB LED RING EXAMPLE<\/a><\/p>\n<h2>\u63a5\u7dda\uff1a<\/h2>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full\" src=\"http:\/\/esp32learning.b-cdn.net\/wp-content\/uploads\/2018\/06\/esp32-and-led-ring_bb.jpg\" width=\"981\" height=\"657\" \/><\/p>\n<h2>\u63a5\u8173\u5b9a\u7fa9\uff1a<\/h2>\n<p>\u74b0\u5f62LED\u662fWS2812\u6676\u7247\uff0c\u4e0a\u9762\u5c31\u4e09\u652f\u63a5\u8173\uff1a<\/p>\n<p>DI:Data Input<\/p>\n<p>5v: \u63a5\u55ae\u6676\u7247\u4e3b\u677f\u4e0a\u7684Vout (3.3V\u62165v)<\/p>\n<p>GND: \u63a5\u5730 ground<\/p>\n<p>DO: Data Output (WS2812\u71c8\u689d\u4e32\u63a5\u4e0b\u4e00\u500b\u7d44\u71c8\u689d\u7528)<\/p>\n<p>\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">#include &lt;Adafruit_NeoPixel.h&gt;\r\n\r\n#define PIN            15\r\n\r\n\/\/ How many NeoPixels are attached to the Arduino?\r\n#define NUMPIXELS      45 \/\/45\u9846LED\r\n\r\nAdafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);\r\n\r\nint delayval = 50; \/\/ delay for half a second\r\n\r\nvoid setup() \r\n{\r\n  pixels.begin(); \/\/ This initializes the NeoPixel library.\r\n}\r\n\r\nvoid loop() \r\n{\r\n  for(int i=0;i&lt;NUMPIXELS;i++)\r\n  {\r\n    \/\/ pixels.Color takes RGB values, from 0,0,0 up to 255,255,255\r\n    pixels.setPixelColor(i, pixels.Color(255,0,0)); \/\/ Moderately bright green color.\r\n    pixels.show(); \/\/ This sends the updated pixel color to the hardware.\r\n    delay(delayval); \/\/ Delay for a period of time (in milliseconds).\r\n  }\r\n\r\n  for(int i=0;i&lt;NUMPIXELS;i++)\r\n  {\r\n    \/\/ pixels.Color takes RGB values, from 0,0,0 up to 255,255,255\r\n    pixels.setPixelColor(i, pixels.Color(0,255,0)); \/\/ Moderately bright green color.\r\n    pixels.show(); \/\/ This sends the updated pixel color to the hardware.\r\n    delay(delayval); \/\/ Delay for a period of time (in milliseconds).\r\n  }\r\n\r\n  for(int i=0;i&lt;NUMPIXELS;i++)\r\n  {\r\n    \/\/ pixels.Color takes RGB values, from 0,0,0 up to 255,255,255\r\n    pixels.setPixelColor(i, pixels.Color(0,0,255)); \/\/ Moderately bright green color.\r\n    pixels.show(); \/\/ This sends the updated pixel color to the hardware.\r\n    delay(delayval); \/\/ Delay for a period of time (in milliseconds).\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><iframe title=\"45\u4f4dLED\u74b0\u5f62\u6d41\u6c34\u71c8\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/zY2IY00v6k0?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>\u7814\u7a76\u9019\u500b\u4e3b\u984c\uff0c\u8acb\u4e0b\u95dc\u9375\u5b57\uff1a<\/p>\n<ol>\n<li>LED Ring\/LED\u74b0\u5f62\u71c8<\/li>\n<li>WS2812<\/li>\n<li>NeoPixel\u7a0b\u5f0f\u5eab<\/li>\n<\/ol>\n<p>\u7528 Google\u641c\u5c0b\u5f8c\uff0c\u518d\u7528\u5716\u7247\u7684\u65b9\u5f0f\u4f86\u627e\u51fa\u9700\u8981\u7684\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u53c3\u8003\u81ea\uff1aESP32 AND WS2812 RGB LED RING EXAM &hellip; <\/p>\n","protected":false},"author":1,"featured_media":14445,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[256],"tags":[104,234,236,235],"class_list":["post-14365","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-256","tag-arduino","tag-esp","tag-led-ring","tag-neopixel"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/14365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/comments?post=14365"}],"version-history":[{"count":7,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/14365\/revisions"}],"predecessor-version":[{"id":14372,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/14365\/revisions\/14372"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media\/14445"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=14365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=14365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=14365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}