Advertisement
Guest User

FastLED Thanksgiving Color Wave

a guest
Nov 7th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define LED_PIN 7
  4. #define NUM_LEDS 300
  5. #define BRIGHTNESS 255
  6. #define LED_TYPE WS2811
  7. #define COLOR_ORDER GRB
  8. CRGB leds[NUM_LEDS];
  9.  
  10. #define UPDATES_PER_SECOND 25
  11.  
  12. // This example shows several ways to set up and use 'palettes' of colors
  13. // with FastLED.
  14. //
  15. // These compact palettes provide an easy way to re-colorize your
  16. // animation on the fly, quickly, easily, and with low overhead.
  17. //
  18. // USING palettes is MUCH simpler in practice than in theory, so first just
  19. // run this sketch, and watch the pretty lights as you then read through
  20. // the code. Although this sketch has eight (or more) different color schemes,
  21. // the entire sketch compiles down to about 6.5K on AVR.
  22. //
  23. // FastLED provides a few pre-configured color palettes, and makes it
  24. // extremely easy to make up your own color schemes with palettes.
  25. //
  26. // Some notes on the more abstract 'theory and practice' of
  27. // FastLED compact palettes are at the bottom of this file.
  28.  
  29.  
  30.  
  31. CRGBPalette16 currentPalette;
  32. TBlendType currentBlending;
  33.  
  34. void setup() {
  35. delay( 3000 ); // power-up safety delay
  36. FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  37. FastLED.setBrightness( BRIGHTNESS );
  38. SetupThanksgivingPalette();
  39. //currentPalette = RainbowColors_p;
  40. currentBlending = LINEARBLEND;
  41. }
  42.  
  43.  
  44. void loop()
  45. {
  46. // ChangePalettePeriodically();
  47.  
  48. static uint8_t startIndex = 0;
  49. startIndex = startIndex + 1; /* motion speed */
  50.  
  51. FillLEDsFromPaletteColors( startIndex);
  52. FastLED.show();
  53. FastLED.delay(1000 / UPDATES_PER_SECOND);
  54. }
  55.  
  56. void FillLEDsFromPaletteColors( uint8_t colorIndex)
  57. {
  58. uint8_t brightness = 255;
  59.  
  60. for( int i = 0; i < NUM_LEDS; i++) {
  61. leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
  62. colorIndex += 3;
  63. }
  64. }
  65.  
  66.  
  67. // There are several different palettes of colors demonstrated here.
  68. //
  69. // FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
  70. // OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
  71. //
  72. // Additionally, you can manually define your own color palettes, or you can write
  73. // code that creates color palettes on the fly. All are shown here.
  74. //not currently used
  75. /*void ChangePalettePeriodically()
  76. {
  77. uint8_t secondHand = (millis() / 1000) % 60;
  78. static uint8_t lastSecond = 99;
  79.  
  80. if( lastSecond != secondHand) {
  81. lastSecond = secondHand;
  82. if( secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; }
  83. if( secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }
  84. if( secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; }
  85. if( secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; }
  86. if( secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; }
  87. if( secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }
  88. if( secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; }
  89. if( secondHand == 40) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; }
  90. if( secondHand == 45) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; }
  91. if( secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }
  92. if( secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
  93. }
  94. }*/
  95.  
  96.  
  97.  
  98. //Candy Cane Stripes
  99. void SetupCandyCanePalette(){
  100. CRGB red = CHSV(HUE_RED,255,255);
  101. CRGB white = CRGB::Gray;
  102.  
  103. currentPalette = CRGBPalette16(
  104. red, red, red, red,
  105. white, white, white, white,
  106. red, red, red, red,
  107. white, white, white, white);
  108. }
  109.  
  110. //Thanksgiving Palette
  111. void SetupThanksgivingPalette(){
  112. CRGB brown = CRGB::Orange;
  113. CRGB golden = CRGB::DarkGoldenrod;
  114. CRGB darkgreen = CRGB::DarkGreen;
  115. CRGB darkorange = CRGB::OrangeRed;
  116. CRGB yellow = CRGB::Yellow;
  117.  
  118. currentPalette = CRGBPalette16(
  119. brown, brown, golden, darkgreen,
  120. darkorange, darkorange, yellow, yellow,
  121. brown, brown, golden, darkgreen,
  122. darkorange, darkorange, yellow, yellow
  123. );
  124.  
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement