Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. FASTLED_USING_NAMESPACE
  4.  
  5. #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
  6. #warning "Requires FastLED 3.1 or later; check github for latest code."
  7. #endif
  8.  
  9. #define DATA_PIN 10
  10. //#define CLK_PIN 4
  11. #define LED_TYPE WS2811
  12. #define COLOR_ORDER GRB
  13. #define NUM_LEDS 20
  14. CRGB leds[NUM_LEDS];
  15.  
  16. #define BRIGHTNESS 96
  17. #define DURATION 2.0
  18.  
  19.  
  20. unsigned long start = 0;
  21.  
  22. void setup() {
  23. // put your setup code here, to run once:
  24.  
  25.  
  26. // tell FastLED about the LED strip configuration
  27. FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  28. //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  29.  
  30. // set master brightness control
  31. FastLED.setBrightness(BRIGHTNESS);
  32.  
  33. start = millis();
  34. }
  35.  
  36. void loop() {
  37. // put your main code here, to run repeatedly:
  38.  
  39. float t = millis() - start;
  40.  
  41.  
  42. if (t <= 10000) {
  43. float seconds = t/1000.0;
  44.  
  45. int st = NUM_LEDS / DURATION * (seconds);
  46. for (int i = 0; i < st; i++) {
  47. leds[i] = CRGB(255, 0, 0);
  48. }
  49. }
  50. else {
  51. for (int i = 0; i < NUM_LEDS; i++) {
  52. leds[i] = CRGB(255, 0, 0);
  53. }
  54. }
  55.  
  56. FastLED.show();
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement