Left for archival purposes.

User avatar
By Mikecay
#11354 Hi,

I am starting a project with the WS2812B leds controlled by a ESP-01 using lua, I have the LEDs on order so I'm just waiting now. I am excited about using the WS2812 library but I was wondering how do you fade in and out the leds or even hold them at say 25% intensity?

Thank you,

Mike
User avatar
By flokli
#11357 Hey @Mikecay,

the ws2812 module simply writes the desired state to all leds at once.

If you want to do fading etc., you need to do this in a loop, which increments and decrements values.
You get lower brightness by sending lower values. 255,255,255 means white, if you send only 100,100,100, you get a much darker light.

So try looping from i from 0 to 255 and back to zero, inside the loop, send (i,i,i) to the ws2812, and wait some usecs ;-)

Florian
User avatar
By Mikecay
#11358 Hi flokli,

Thank you for the quick reply. I understand that using 100,100,100 will be a darker light, maybe even more on the gray/black side but it is still at 100% intensity. Maybe fade was the wrong word to use, what I want is to dim the lights. so use 255,255,255 but dim it to say 50%. I know there is a pwm.setduty command, will that also work with the WS2812 leds?

Mike
User avatar
By flokli
#11389 No, this won't work. If you want to lower the overall brightness, I'd suggest multiplying each color value with a factor before sending it to the ws2812 module.