Advertisement
JasonB11

FastLEDxmas2014.ino

Nov 23rd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. //  Example showing how to make a simple striped color palette,
  4. //  and use it to animated blended color bars
  5.  
  6. #define LED_PIN     A0
  7. #define NUM_LEDS    10
  8. CRGB leds[NUM_LEDS];
  9.  
  10. CRGBPalette16 currentPalette;
  11.  
  12. void setupStripedPalette( CRGB A, CRGB AB, CRGB B, CRGB BA)
  13. {
  14.   // Sets up a palette with alternating stripes of
  15.   // colors "A" and "B" -- with color "AB" between
  16.   // where A fades into B, and color "BA" where B fades
  17.   // into A.
  18.   // The stripes of "A" are narrower than the stripes of "B",
  19.   // but an equal-width arrangement is also shown.
  20.   currentPalette = CRGBPalette16(
  21.    //     A, A, A, A, AB, B, B, B, B, B, B, B, B, B, B, BA
  22.       A, A, A, A, A, A, A, AB, B, B, B, B, B, B, B, BA
  23.   );
  24. }
  25.  
  26. void setup() {
  27.   delay( 3000 ); // power-up safety delay
  28.   FastLED.addLeds<TM1803,LED_PIN,GBR>(leds, NUM_LEDS);
  29.  
  30.   // This example shows stripes with NO gaps between them; the colors
  31.   // cross-fade at the boundaries.  An additional setup alternative is
  32.   // provided that puts a 'black' gap between the colors, so they don't
  33.   // bleed into each other if you prefer that.
  34.  
  35.   // Color stripes with NO gaps between them -- colors will crossfade (testing different colors)
  36.   //setupStripedPalette( CRGB::Salmon, CRGB::Goldenrod, CRGB::Goldenrod, CRGB::Salmon);
  37.   //setupStripedPalette ( CRGB::Red, CRGB::Red, CRGB::Green, CRGB::Green);
  38.   //setupStripedPalette ( CRGB::DeepPink, CRGB::DeepPink, CRGB::Goldenrod, CRGB::Goldenrod);
  39.   //setupStripedPalette ( CRGB::Coral, CRGB::Coral, CRGB::Cornsilk, CRGB::Cornsilk); //cornsilk is too blue
  40.   //setupStripedPalette ( CRGB::Coral, CRGB::Coral, CRGB::LemonChiffon, CRGB::LemonChiffon); //too blue
  41.     setupStripedPalette( CRGB::Coral, CRGB::Coral, CRGB::Goldenrod, CRGB::Goldenrod);
  42.  
  43.  
  44.   // Color stripes WITH gaps of space (black) between them
  45.   //setupStripedPalette( CRGB::Red, CRGB::Black, CRGB::Green, CRGB::Black);
  46. }
  47.  
  48.  
  49. void loop()
  50. {
  51.   static uint8_t startIndex = 0;
  52.   startIndex = startIndex - 2; /* higher = faster motion */
  53.  
  54.   fill_palette( leds, NUM_LEDS,
  55.                 startIndex, 50, /* higher = narrower stripes */
  56.                 currentPalette, 255, BLEND);
  57.  
  58.   FastLED.show();
  59.   FastLED.delay(1000 / 60);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement