对应于arduino中的fastled库中的blink例子,没啥好说的,也没啥算法,简单就可以理解。
/// @file Blink.ino
/// @brief Blink the first LED of an LED strip
/// @example Blink.ino
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 108
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define DATA_PIN 2
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
// Uncomment/edit one of the following lines for your leds arrangement.
// ## Clockless types ##
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
}
void loop() {
// Turn the LED on, then pause
for(int i=0;i<NUM_LEDS;i+=5)
leds[i] = CRGB::Green;
FastLED.show();
delay(500);
// Now turn the LED off, then pause
for(int i=0;i<NUM_LEDS;i++)
leds[i] = CRGB::Black;
FastLED.show();
delay(500);
}
37

被折叠的 条评论
为什么被折叠?



