Makes fading leds on an Arduino easy.
By Timo Engelgeer (Septillion)
Fading is easy right? But it can quickly become quite some code to do so. FadeLed does all the heavy lifting for you. It can fade every led on a hardware PWM pin (capable of
analogWrite()). Just make a FadeLed object for it, set the fade time and just set the brightness to fade to. You can let it fade to and from each brightness you like!
FadeLed can fade in two modes, constant fade speed (default) and constant fade time. The mode can be selected for each led.
This is the default mode. A led will fade with a constant speed. The time you set is the time of a full fade from off to full brightness or vice versa. If the fade is not full scale, for example to/from halve brightness, it will take less time. In the case of halve brightness it will take halve the time.
Each fade will now take the same amount of time. No matter if you fade the full scale or just just by 10 steps, it will take the same time.
librariesfolder inside your Sketchbook. Default is
FadeLed(remove version number).
Using FadeLed is simple. Just make a FadeLed object for each led you want to fade like
It’s also possible to make an array of multiple FadeLed-objects which can make it easy to loop over each.
In order to update the fading of all FadeLed objects you just have to call
FadeLed::update() frequently. So it’s best to have a non-blocking loop and call it like
Calling this function will set the time a fade needs to take. By default it will set the time a full fade should take (constant fade speed). But by entering
true as second parameter you can change that to the time each fade should take (constant fade time). You can change the fade time anytime you like! The time is set in milliseconds
The most common function of the library. Simply sets the brightness to fade to.
There are also the shortcuts
.off() to simply fade to full on or full off respectively.
Other useful methods of the library include
FadeLed::setInterval(). For documentation of all the methods, see the full documentation.
For more information see the GitHub page: FadeLed on GitHub
Full documentation of all the methods of this library can be found inside the library located in
FadeLed\doc. Just open
FadeLed\doc\index.html to see all methods of FadeLed.