Skip to content

Arduino library for RGB+W leds. Implements HSI colour space and Kelvin color temperatures.

License

Notifications You must be signed in to change notification settings

Susensio/RGBWLed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGBWLed library for Arduino

Arduino library for interfacing with RGB+W leds. Implements HSI colorspace and Color temperature besides raw RGBW manipulation. Allows smooth non blocking fading between colors in all colorspaces. Corrects for non-linear brightness when using PWM.

Fading interpolation in Color temperature between two kelvin values results in natural colors, perfect for representing sunrise and sunset effects.

Color temperature scale

Installation

  1. Download the library from GitHub repository
  2. Open Arduino IDE
  3. Go to Sketch > Include Library > Add .ZIP Library...
  4. Search for the downloaded file

Usage

Include the library at the start of your code and initialize pins as OUTPUT

#include <RGBWLed.h>

RGBWLed (byte redPin, byte greenPin, byte bluePin, byte whitePin);

Simple functions to change the led color

// red, green and blue are [0..255] values, raw values
void writeRGBW(byte red, byte green, byte blue, byte white);

// red, green and blue are [0..255] values, dim correction
void setRGBW(byte red, byte green, byte blue, byte white);

// hue in degrees, saturation normalized [0..1] and intensity 8-bits [0..255]
void setHSI(float hue, float sat, byte in);

// temp in Kelvin, intensity 8-bits [0..255]
void setKelvin(float temp, byte in);

Asynchronus functions, void updateFade(); is needed to change led output

// Sets global intensity
void setIntensity(byte value);

// Fade functions, duration in seconds
void fadeHSI(HSI initcolour, HSI endcolour, unsigned int duration_s, unsigned int steps);
void fadeKelvin(Kelvin initcolour, Kelvin endcolour, unsigned int duration_s, unsigned int steps);

// Needs to be called periodically to update fade progress and apply global intensity
void updateFade(void);

// Helper functions
boolean isFading(void);
void pauseFade(void);
void resumeFade(void);

Credits

About

Arduino library for RGB+W leds. Implements HSI colour space and Kelvin color temperatures.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages