I am working on some animations and I cant quite figure out what to

fastled-support
gplus
(Will Norton) #1

I am working on some animations and I cant quite figure out what to do with this one. I’m trying to create a star effect, that displays a random amount of stars of random pixel lengths from 1 to 4 leds long. I also want the “star” to stay on for a random amount of time and flicker a bit before fading to black. the code I have written is very simple and looks interesting (i might keep this, but as a separate animation) but it doesn’t do what I want it to do. This is what Ive written so far. BTW im also using RGBset but for this sample im addressing the whole strip instead of a set of the strip.

void stars() {
fadeToBlackBy(strip1, NUM_LEDS-1, 10);
int pos = random8(NUM_LEDS);
int len = random(0, 3);
strip1(pos, pos+len) = CRGB::White;
}

(Will Norton) #2

Also, i forgot to mention, I don’t want so many stars to appear that it completely fills the strip of leds. since I’m going to use two way mirrors to create a infinity mirror effect, i only want a few stars to be on one strip at a time. the mirrors will make it look like there are a lot more than there actually are.

(Marc Miller) #3

More random needed! :slight_smile:

Ideas for two things you can try:

A) make it random how often the stars function is called. See this example for how to use EVERY_N with a variable length time, line 58 and 62. You will probably want to pull the fade to black outside of the function of it looks funny still being in there after this change.

B) add an if with another random inside the stars function that causes the setting of pixels white to only happen a certain percentage of the time. For example:

if (30 > random8(101) {
//this only runs 30% of the time
//Do stuff here…
}

(Marc Miller) #4

Forgot the link to go with A)

(Dougal Campbell) #5

Your description sounds very similar to what I did in my “eyeblink” halloween project. I used the NeoPixel library, but it would be easy to adapt to FastLED.

I actually meant to write an interface shim that would let you easily switch between the two libraries, but never got around to it.

(Dougal Campbell) #6

Oops, forgot to paste the link: