#include <Adafruit_NeoPixel.h>
#define DIN_PIN 19 // ESP32 connected to WS2812B_Din
#define LED_CNT 2 // 8個燈
//變數名稱為leds的Adafruit_NeoPixel 類別
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_CNT, DIN_PIN, NEO_GRB + NEO_KHZ800);
int led=33;
void setup() {
pinMode (DIN_PIN, OUTPUT); //串列輸出腳
pinMode(led, OUTPUT);
leds.begin(); //初始化
}
void loop() {
//leds.clear(); //清除
for (int i = 0; i < 8; i++) {
leds.setPixelColor(i, leds.Color(255, i, 255-16*i)); //紅
leds.show();
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, 0);
delay(100);
}
delay(100);
}