Go Down

Topic: Advice on how best to approach randomly blinking WS2811 leds (Read 144 times) previous topic - next topic

grogking

Hi,
I'm fairly new at this. I have a string of 12 WS2811 leds that I would like to do the following:
 - Randomly blink on and off certain leds for a time set between 4 and 6 seconds
 - Keep certain of those leds on constantly.
 - Be able to set the color of the whole strand to the same color

This process would be automatic and require no inputs.

In other words. I would like led 2, 3,4 6 and 8 to blink on for 4 to 8 seconds, and then off for 4 to 8 seconds, and I would like led 0,1,5,7 and 9-11 to remain on the whole time. I would like all the leds to be this RGB color 255, 214,170.

Which library would be best for this, neopixel or fastLED? Can you give me some guideance as to how to accomplish this? I am currently thinking of using switch  and case, but I am not sure this is the best way to go about this.

Thanks!

Grumpy_Mike

Using either library you get a function call to set a specific led to a colour. The led is identified by a number and the colour by three numbers representing the red, green and blue which is off to 255 which is full brightness.

Run the examples that cone with the libiary to learn how this works.

Blinking is easy, first run a function to set all the LEDs to off, followed by turning on the LEDs you want to be on at this stage. Then call the show function and repeat this after a time which corresponds to how fast you want to blink them but now turning on a different set.

You need to know how for loops work to make the code tolerable to read. If you write the same instructions with different numbers in them over and over, then their is an easier way of doing the code.

Build things up one step at a time, don't try and do everything at once. Eventually you will use a switch / case structure but not in the beginning.

grogking


Go Up