Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // *********************************
- // **** TRYING TO FIGURE OUT ****
- // **** A PULSING PATTERN THAT ****
- // **** CHANGES COLOR BY ****
- // *** NESTING LOOPS *****
- // *********************************
- //
- // ******************
- // *** UNTESTED ***
- // ******************
- //
- #include "FastLED.h"
- #define DATA_PIN 8
- //#define CLK_PIN 4
- #define NUM_LEDS 12
- //
- CRGB leds[NUM_LEDS];
- //
- // *** NOTE TO SELF
- // Might not need the below three lines once sketch is tweaked.
- int pulseFade = 5; // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
- int pulseBrightness = 0;
- int pulseHue = 0; // Sets the initial color for the pulse effect to red.
- //
- void setup()
- {
- //
- delay(3000); // 3 second delay for recovery
- //
- //FastLED.setBrightness(96);
- //
- FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
- //
- } // END OF VOID SETUP
- //
- void loop()
- //
- {
- for(int pulseHue = 0; pulseHue < 256; pulseHue = pulseHue + 32)// -- do I need +=32 ?
- {
- //
- for(int i = 0; i < NUM_LEDS; i++ )
- {
- leds[i] = CHSV(pulseHue, 255, 255);
- leds[i].fadeLightBy(pulseBrightness);
- }
- pulseBrightness = pulseBrightness + pulseFade;
- // reverse the direction of the fading at the ends of the fade:
- if(pulseBrightness == 0 || pulseBrightness == 255)
- {
- pulseFade = -pulseFade ;
- }
- //
- }
- FastLED.show(); //AS PER DANIEL GARCIA, TRY TO MOVE THESE TWO LINES ABOVE THE } JUST ABOVE
- delay(20); // This delay sets speed of the fade.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement