SHOW:
|
|
- or go back to the newest paste.
| 1 | // | |
| 2 | // ********************************* | |
| 3 | - | // **** TRYING TO FIGURE OUT **** |
| 3 | + | // *** A PULSING PATTERN THAT *** |
| 4 | - | // **** A PULSING PATTERN THAT **** |
| 4 | + | // *** CHANGES COLOR BY *** |
| 5 | - | // **** CHANGES COLOR BY **** |
| 5 | + | // *** NESTING LOOPS *** |
| 6 | - | // *** NESTING LOOPS ***** |
| 6 | + | |
| 7 | // | |
| 8 | // ****************** | |
| 9 | // *** WORKS *** | |
| 10 | - | // *** UNTESTED *** |
| 10 | + | |
| 11 | // | |
| 12 | #include "FastLED.h" | |
| 13 | #define DATA_PIN 8 | |
| 14 | //#define CLK_PIN 4 | |
| 15 | #define NUM_LEDS 12 | |
| 16 | // | |
| 17 | CRGB leds[NUM_LEDS]; | |
| 18 | // | |
| 19 | // | |
| 20 | - | // *** NOTE TO SELF |
| 20 | + | |
| 21 | - | // Might not need the below three lines once sketch is tweaked. |
| 21 | + | |
| 22 | - | int pulseFade = 5; // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255. |
| 22 | + | |
| 23 | - | int pulseBrightness = 0; |
| 23 | + | |
| 24 | - | int pulseHue = 0; // Sets the initial color for the pulse effect to red. |
| 24 | + | |
| 25 | //Below sets overall brightness ratio for entire sketch | |
| 26 | // in this case 96/256ths | |
| 27 | //FastLED.setBrightness(96); | |
| 28 | // | |
| 29 | FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); | |
| 30 | // | |
| 31 | - | //FastLED.setBrightness(96); |
| 31 | + | |
| 32 | // | |
| 33 | void loop() | |
| 34 | // | |
| 35 | {
| |
| 36 | // =================================================================================================================THIS IS THE OUTER LOOP START | |
| 37 | for(int pulseHue = 0; pulseHue < 256; pulseHue = pulseHue + 32)// | |
| 38 | {
| |
| 39 | // | |
| 40 | - | for(int pulseHue = 0; pulseHue < 256; pulseHue = pulseHue + 32)// -- do I need +=32 ? |
| 40 | + | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>THIS IS THE MIDDLE LOOP START |
| 41 | for (int pulseBrightness = 255; pulseBrightness > 0; pulseBrightness = pulseBrightness - 7) // The -# is the rate of fade | |
| 42 | {
| |
| 43 | - | for(int i = 0; i < NUM_LEDS; i++ ) |
| 43 | + | |
| 44 | //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -THIS IS THE INNER LOOP START | |
| 45 | - | leds[i] = CHSV(pulseHue, 255, 255); |
| 45 | + | for(int i = 0; i < NUM_LEDS; i++ )// |
| 46 | - | leds[i].fadeLightBy(pulseBrightness); |
| 46 | + | |
| 47 | - | } |
| 47 | + | |
| 48 | - | pulseBrightness = pulseBrightness + pulseFade; |
| 48 | + | leds[i] = CHSV(pulseHue, 255, pulseBrightness); |
| 49 | - | // reverse the direction of the fading at the ends of the fade: |
| 49 | + | |
| 50 | - | if(pulseBrightness == 0 || pulseBrightness == 255) |
| 50 | + | |
| 51 | }//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -THIS IS THE INNER LOOP END | |
| 52 | - | pulseFade = -pulseFade ; |
| 52 | + | |
| 53 | - | } |
| 53 | + | FastLED.show(); |
| 54 | // | |
| 55 | - | } |
| 55 | + | delay (100); //sets the speed of the fade |
| 56 | - | FastLED.show(); //AS PER DANIEL GARCIA, TRY TO MOVE THESE TWO LINES ABOVE THE } JUST ABOVE |
| 56 | + | }// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>THIS IS THE MIDDLE LOOP END |
| 57 | - | delay(20); // This delay sets speed of the fade. |
| 57 | + | |
| 58 | - | } |
| 58 | + | }// =================================================================================================================THIS IS THE OUTER LOOP END |
| 59 | // | |
| 60 | }// VOID LOOP END |