Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- FASTLED_USING_NAMESPACE
- #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
- #warning "Requires FastLED 3.1 or later; check github for latest code."
- #endif
- #define DATA_PIN 10
- //#define CLK_PIN 4
- #define LED_TYPE WS2811
- #define COLOR_ORDER GRB
- #define NUM_LEDS 20
- CRGB leds[NUM_LEDS];
- #define BRIGHTNESS 96
- #define DURATION 2.0
- unsigned long start = 0;
- void setup() {
- // put your setup code here, to run once:
- // tell FastLED about the LED strip configuration
- FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- // set master brightness control
- FastLED.setBrightness(BRIGHTNESS);
- start = millis();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- float t = millis() - start;
- if (t <= 10000) {
- float seconds = t/1000.0;
- int st = NUM_LEDS / DURATION * (seconds);
- for (int i = 0; i < st; i++) {
- leds[i] = CRGB(255, 0, 0);
- }
- }
- else {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB(255, 0, 0);
- }
- }
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement