If you need to control a series of led activities/patterns in a non-blocking fashion then this library is for you.
- Non-blocking
- Fluent API Interface
- Define a chain of led activity configurations that you can assign, reuse and playback for any led instance.
- More flexibility in controlling the light patterns for complex activities
-
Browse to the arduino library/sketchbook location
-
Navigate to the libraries folder
-
Clone the repository into the libraries folder
git clone https://github.com/ribasco/Led-Flow.git
-
Restart the Arduino IDE (If open)
-
In your sketch, include the library by typing
#include <LedFlow.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
or simply via the Arduino Menu
Sketch -> Include Library -> Led Flow
Please note that using the setValue* methods are the same as calling analogWrite(value).
- Turning on/off a Standard LED
#include <LedFlow.h>
#define PIN_LED 6
LedSingle ledSingle = LedSingle(PIN_LED);
void setup() {
//Turn On: Set to the maximum brightness (255)
ledSingle.setValue(255);
//Turn off
//ledSingle.setValue(0);
}
void loop() {
}
- Turning on/off an RGB LED
#include <LedFlow.h>
#define PIN_LED_R 2
#define PIN_LED_G 3
#define PIN_LED_B 4
LedRgb ledRgb = LedRgb(PIN_LED_R, PIN_LED_G, PIN_LED_B);
void setup() {
//Set the value of all pins
ledRgb.setValue(RGB(255, 0, 0));
//The following code below individually sets the color value of each RGB Pin.
// Using this method will not override the values of the other pins.
//ledRgb.setValueRed(0);
//ledRgb.setValueGreen(255);
//ledRgb.setValueBlue(255);
}
void loop() {
}