At first glance, Confetti, Juggle and Sinelon are relatively easy functions to merge into existing code.
Assuming you'll be using the FastLED library, since they use FastLED specific functions, like random16, beatsin16 , CHSV and fadeToBlack.
void confetti()
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
However, these functions have been written with loops in mind so after each call of a function one will need to do this to make it visible:
FastLED.show();
Additionally a global variable is being used called gHue:
uint8_t gHue = 0;
The code in DemoReel100 uses nicely the EVERY_N_MILLISECONDS and EVERY_N_SECONDS macros, and the option to pass a value to FastLED.show().
For beginners this may be a little bit daunting, and personally I do not use these options too often because of that.
So instead of using EVERY_N_MILLISECONDS you could try something like this, for example for confetti:
...
uint8_t gHue = 0;
...
void setup() {
...
}
void loop() {
confetti(); // Do a step for Confetti
FastLED.show(); // show the current step
delay(20); // wait 20 milliseconds before doing the next step in Confetti
gHue++;
}
This will do a confetti step, show the step result (leds change color), wait 20 milliseconds, increase hue, and do it all again since the loop will keep repeating itself.
It would almost be the same as using the EVERY_N_MILLISECONDS.
EVERY_N_MILLISECONDS however is a macro which may result in better timing - but I found that with effects, timing isn't always (!) that critical.
The DemoReel changes effect every 10 seconds (EVERY_N_SECONDS), but we can do this "manually" as well.
For example: You could put that in a loop, so that it does for example Confetti 100 times, so it can do the next effect after competing that. For example:
void loop() {
for(int i=0; i<100; i++) { // 100 times confetti
confetti(); // Do a step for confetti
FastLED.show(); // show the current step
delay(20); // wait 20 milliseconds before doing the next step in confetti
gHue++;
}
for(int i=0; i<100; i++) { // 100 times sinelon
sinelon(); // Do a step for sinelon
FastLED.show(); // show the current step
delay(20); // wait 20 milliseconds before doing the next step in sinelon
gHue++;
}
}
The same way you can add Juggle.
Play with it and see how it does 😀