给我写一个esp8266驱动ws2812灯珠的代码
时间: 2023-03-08 21:07:32 浏览: 352
基于ESP8266 驱动 WS2812B的智能灯(操作说明+驱动源码等)-电路方案
我建议你参考以下代码:
#include <Arduino.h>
#define LED_COUNT 8
#define LED_PIN 5CRGB leds[LED_COUNT];void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812, LED_PIN, RGB>(leds, LED_COUNT);
}void loop() {
for (int i=0; i<LED_COUNT; i++) {
leds[i] = CRGB::Red;
FastLED.show();
delay(50);
} for (int i=0; i<LED_COUNT; i++) {
leds[i] = CRGB::Blue;
FastLED.show();
delay(50);
}
}
阅读全文