Language: EN


Arduino ColorConverter Library

The ColorConverter library contains simple functions to convert colors between different systems (RGB, HSV, HSL, Temperature).

User Manual

The library consists of static functions that perform color conversion. Therefore, it is not necessary to instantiate an object, we only need to call the desired conversion function.

We can convert from RGB to HSV or HSL and vice versa. We can also convert from color temperature in Kelvin to RGB.

static void RgbToHsv(uint8_t r, uint8_t g, uint8_t b, double &hue, double &saturation, double &value);
static void RgbToHsl(uint8_t red, uint8_t green, uint8_t blue, double &hue, double &saturation, double &lighting);  
static void HsvToRgb(double hue, double saturation, double value, uint8_t & red, uint8_t & green, uint8_t & blue);
static void HslToRgb(double hue, double saturation, double lightness, uint8_t &red, uint8_t &green, uint8_t &blue);
static void TemperatureToRgb(int kelvin, uint8_t & red, uint8_t & green, uint8_t & blue);


The ColorConverter library includes the following examples to illustrate its use.

  • ColorConverter: Example showing the use of some of the conversion functions.
#include "ColorConverterLib.h"

void setup() 
  uint8_t red = 50;
  uint8_t green = 100;
  uint8_t blue = 150;
  double hue, saturation, lighting, value;
  ColorConverter::RgbToHsl(red, green, blue, hue, saturation, lighting);
  ColorConverter::RgbToHsv(red, green, blue, hue, saturation, value);
  ColorConverter::HslToRgb(hue, saturation, lighting, red, green, blue);
  ColorConverter::HsvToRgb(hue, saturation, lighting, red, green, blue);

  ColorConverter::TemperatureToRgb(15000, red, green, blue);

void loop() 


  • Download the latest version from GitHub
  • Unzip the file
  • Copy to your libraries folder (usually My Documents\Arduino\libraries)
  • Restart the Arduino IDE