esp32c3 WS2812 用法

180it 2025-02-15 PM 55℃ 0条
#include "Freenove_WS2812_Lib_for_ESP32.h"

#define LEDS_COUNT  8
#define LEDS_PIN    8
#define CHANNEL        0

Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, LEDS_PIN, CHANNEL, TYPE_GRB);

/*
# 定义颜色 (R, G, B)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
PURPLE = (255, 0, 255)
CYAN = (0, 255, 255)
WHITE = (255, 255, 255)
OFF = (0, 0, 0)
*/



void setup() {
    strip.begin();
    strip.setBrightness(200);    

    Serial.begin(115200);
  Serial.print("Timer");
}
void loop() {


    // 设置第 0 个 LED 为红色
  strip.setLedColorData(0, 255, 255, 0);  // 红色
  strip.show();  // 更新 LED 显示
  delay(1000);

  // 设置第 1 个 LED 为绿色
  strip.setLedColorData(0, 0, 0, 0);  // 绿色
  strip.show();  // 更新 LED 显示
  delay(1000);

  // 设置第 2 个 LED 为蓝色
  strip.setLedColorData(0, 255, 255, 255);  // 蓝色
  strip.show();  // 更新 LED 显示
  delay(1000);


}
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

esp32c3 WS2812 用法