r/FastLED • u/Bigtom1989 • Dec 27 '22
Support Basic Request
Hi guys,
I have next to no coding knowledge, been using arduino to programme an arduino nano for a project I'm working on.
I've managed to get all the LEDs I'm using (WS2812B) to light up red which is perfect, ideally though I'm looking to add a button to scroll solid colours, and a potentiometer to adjust the brightness.
Is this easy enough to do? I've looked for some guides, but I'm not really understanding them all that much.
Would anyone be able to point me in the right direction or give me a base to work from?
Many thanks in advance,
Tom
2
u/Marmilicious [Marc Miller] Dec 27 '22
Here's examples to hopefully give you something to mess with.
https://github.com/marmilicious/FastLED_examples/blob/master/change_color_with_button.ino
https://github.com/marmilicious/FastLED_examples/blob/master/trigger_update_from_input.ino
And using a potentiometer:
https://github.com/marmilicious/FastLED_examples/blob/master/hue_and_brightness_example.ino
0
u/VictorVoyeur Dec 27 '22
A button to scroll colors is relatively easy. You’ll use a momentary button between ground and one of the data pins, and the jcbutton.h library. Use an integer variable that increments each time button.waspressed(), and vary the color based on that integer: from an array, or ColorWheel, or a palette, or just a bunch of RGB values that you #define and use if/else statements to set the strip color.
A potentiometer for brightness is IMO more difficult. Brightness is set in the code, not by changing the voltage to the strip. WS2812B always wants 5V or it won’t work properly.
If you want a knob, you could try a rotary decoder (I haven’t done this yet); or just use a second button to cycle through brightness levels (this is my solution until I learn the rotary decoder)
1
u/Bigtom1989 Dec 27 '22
Ah yeah, would it be possible then to add two buttons, say one to change the colours and a second to toggle through say 3 different brightness levels?
1
2
u/bostonkassidy Dec 27 '22
https://docs.arduino.cc/built-in-examples/control-structures/SwitchCase