Guest User

LED strip color changer

a guest
Nov 30th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. // FastLED
  2. #include <FastLED.h>
  3.  
  4. #define NUM_LEDS 60
  5. #define DAT_PIN 2
  6. #define TAIL_LENGTH 32
  7.  
  8. int COLOR_POS = 10;
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12. void setup() {
  13.   FastLED.addLeds<NEOPIXEL, DAT_PIN>(leds, NUM_LEDS);
  14. }
  15.  
  16. void loop() {
  17.   // Changing COLOR Loop
  18.  for(int COLOR = 0; COLOR < 255; COLOR = COLOR + 35) {
  19.    
  20.    // Changing LED Loop
  21.     for(int POS = 0; POS < NUM_LEDS; POS++){
  22.  
  23.         leds[POS] = CHSV(COLOR, 255, 255);
  24.  
  25.     FastLED.show();
  26.     //Code to change LED cover depending on current position of the LED
  27.       if (POS > COLOR_POS ){
  28.         COLOR = COLOR + 70;
  29.         COLOR_POS = COLOR_POS + 10;
  30.       } else if (COLOR_POS >= 70) {
  31.         COLOR_POS = 10;
  32.       }
  33.       //Fading loop
  34.     for(int fade = 0; fade < NUM_LEDS; fade++) {
  35.       leds[fade].fadeToBlackBy(TAIL_LENGTH);
  36.     delay(01);
  37.     }    
  38.    }
  39.   }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment