Here’s some quick and dirty fading twinkles:
void twinkle() {
int i = random(800); // A random number. Higher number => fewer twinkles.
if (i < NUM_LEDS) leds[i] = CHSV(50, 100, 255); // Only the lowest probability twinkles will do. You could even randomize the hue/saturation. .
for (int j = 0; j <NUM_LEDS; j++) leds[j]–; // Go through the array and reduce each RGB value by 1 (won’t reduce RGB value to -1, which is awesome).
LEDS.show();
delay(2); // Higher number => slower twinkles.
}
The library has a random8() function that is super fast, compared to random()
Forgot about that, however random16 is required, as I need numbers > 255. Come to think of it, I think I’ll check all my other random’s as well.
And while your at it, might as well use LEDS.delay() too.
I haven’t seen a reference for LEDS.delay, but I’ll look around. There’s also fadetoblack and nscale8, so lots of twinkle possibilities with just a few lines of code. .
LEDS.delay() is 2.1 beta version of FastLED
“Dirty fading twinkles” sounds like a particularly unkind Playa name 
We should probably start documenting 2.1 features in the FastLED wiki soon…
I remember when the library transitioned from FastSPI to FastLED, the documentation changed over night. Mark and Daniel are great at populating the wiki alongside ‘official’ library releases. This forum is a great place to learn, basically, from other peoples problems. Troubleshoot along with them, take the time to read old postings(I guarantee there is content I reference every once and a while that was months ago).and if you ask nice enough, people might even share code with you too!
This code could benefit from being a class object too.
@Ashley_M_Kirchner_No - I hope to figure out how to do that one of these days. Am not there yet.
Quick and dirty fading twinkles? I resemble that…