-
WS2812FX-master.zip下载
资源介绍
WS2812控制LED灯程序库
#include "FastLED.h" // be sure to install and include the FastLED lib
#include
#define NUM_LEDS 30
#define LED_PIN 5
WS2812FX ws2812fx = WS2812FX(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
// declare global parameters used by Fire2012
bool gReverseDirection = false;
void setup() {
Serial.begin(115200);
// init WS2812FX to use a custom effect
ws2812fx.init();
ws2812fx.setBrightness(255);
ws2812fx.setColor(BLUE);
ws2812fx.setSpeed(1000);
ws2812fx.setMode(FX_MODE_CUSTOM);
ws2812fx.setCustomMode(myCustomEffect);
ws2812fx.start();
}
void loop() {
ws2812fx.service();
}
// in the custom effect run the Fire2012 algorithm
uint16_t myCustomEffect() {
Fire2012();
// return the animation speed based on the ws2812fx speed setting
return (ws2812fx.getSpeed() / NUM_LEDS);
}