#include <Adafruit_NeoPixel.h>
#define DIN_PIN 22 // 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%3, leds.Color(8*i, 16*i, 255-16*i)); //紅
leds.show();
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, 0);
delay(60);
}
delay(500);
}