Go Down

Topic: Controlling groups of WS2812 LEDs RGB values based on a few momentary switches? (Read 93 times) previous topic - next topic

Lightguy_05

Hi there!

I'm working on a project that will be using between 100 and 150 WS2812 LED's on a strip, controlled by a Leo. Using the FastLED Library.

Basically, this is what I'm hoping to accomplish:

When the arduino powers up, all the LED's default to an RGB value - need to be able to define certain pixels to turn on in the strip (i.e. LEDs 0-14, 19-45, 51-72, etc).

There are four N/C switches wired into A0-A3, that are normally pulling to ground unless they are pressed momentarily.

When one of the four switches is triggered, a group of LED's change from the default RGB value to a new RGB value, and remain static UNTIL a different switch is triggered. At that point, the original grouping of "triggered" LEDs go back to the default RGB value at startup, and the group of LED's assigned to "A2" pin will turn on.

So the logic looks like this:

At startup, all LEDs 0-150 are set to a defined RGB value 120,255,14 (we'll call this "default").

When A0 is pulled up from ground momentarily, LEDs 0-40 change from "default" to 0,0,255. LEDs 41-150 remains the original RGB value default.

When A1 is pulled up front ground momentarily, LEDs 0-40 change back to the "default" RGB value, and then LEDs 41-92 change to 0,255,0. etc, etc..

These are reed switches, so I will also probably need to include some debouncing to filter out false triggers.

I've not done much coding aside from modifying existing code, so if anyone can link or direct me towards any tutorials or example codes, that would be really helpful! I feel like such a noob, since I know this is actually quite simple to do, just not sure where to start.

Thank you!!

PaulRB

It's safer and easier to have your inputs pulled up to high using the internal pull-ups and have switches pull them down to low when switches are closed.

Not sure why you think you need to de-bounce the switches, given your explanation of the operation on the circuit.

I can't suggest any code examples, but this sounds very straight-forward to me.

Go Up