本站改版新增arduino频道
arduino WS2812 彩色LED基本用法
#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);
}
Copyright © 2014 ESP56.com All Rights Reserved  
晋ICP备14006235号-22 晋公网安备14108102001165号    
执行时间: 0.0094099044799805 seconds