-
-
Save focalintent/a3c4532383fb071abed8b879a22cab73 to your computer and use it in GitHub Desktop.
tweaking for loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ********************************* | |
// **** 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.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); | |
} // END OF VOID SETUP | |
void loop() | |
{ | |
static int pulseHue = 0; | |
if(pulseHue >= 256) { pulseHue = 0; } | |
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(); | |
delay(20); // This delay sets speed of the fade. | |
pulseHue += 32; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment