#ifndef WS2812_FASTLED_H #define WS2812_FASTLED_H #include //控制RGB灯的库文件 #define NUM_LEDS 8 //灯珠的数量,若改造成其他数量自行更改 #define LED_DT 17 //RGB灯上DI信号输入接引脚 #define LED_TYPE WS2812 //WS2812LED灯内置芯片对应的型号 #define COLOR_ORDER GRB //WS2812LED灯对应的色彩顺序 uint8_t max_bright=127; //可改变此值调节LED灯的最大亮度(0-255)建议不要太亮对眼睛不好 uint8_t min_bright=5; //可改变此值调节LED灯的最小亮度(0-255) uint8_t rgb_bright=50; //可改变此值调节LED灯的默认亮度(0-255)建议不要太亮对眼睛不好 uint8_t lightState=0; //可改变此值调节默认的灯开关模式,默认为模式1,0为关 //可增加更多的变化模式 #define LED_DT1 14 //左摇杆RGB灯上DI信号输入接引脚 #define LED_DT2 16 //右摇杆RGB灯上DI信号输入接引脚 #define twinkleInterval 200 // 摇杆LED星闪模式,闪烁间隔时间 (毫秒) #define twinkleChance 20 // 闪烁数量,数值越大闪烁越多(0-255) CRGB leds[NUM_LEDS]; //LED建立对象等 CHSV myHSVcolor(0,255,rgb_bright); CRGB leds1[NUM_LEDS]; //左摇杆LED建立对象等 CRGB leds2[NUM_LEDS]; //右摇杆LED建立对象等 //int thisdelay = 15; // Standard delay uint8_t thisdiff = 1; // Standard palette jump bool thisdir = 0; // Standard direction uint8_t thisindex = 0; // Standard palette index uint8_t thisrot = 1; // You can change how quickly the hue rotates for this wave. Currently 0. //uint8_t thatrot = 0; // You can change how quickly the hue rotates for the other wave. Currently 0. void FastLED_ini(){ // LEDS.addLeds(leds,NUM_LEDS); //LED初始化 // LEDS.addLeds(leds1,NUM_LEDS); //LED初始化 // LEDS.addLeds(leds2,NUM_LEDS); //LED初始化 FastLED.setBrightness(rgb_bright); //设置LED亮度 } void rainbow_march() { // The fill_rainbow call doesn't support brightness levels if (thisdir == 0) thisindex += thisrot; else thisindex-= thisrot; // I could use signed math, but 'thisdir' works with other routines. fill_rainbow(leds, NUM_LEDS, thisindex, thisdiff); // I don't change deltahue on the fly as it's too fast near the end of the strip. } // rainbow_march() void addGlitter(uint8_t chanceofGlitter){ //随机闪光灯效果 if (random8()