void setup() { m.setMode(RGBMood::RANDOM_HUE_MODE); // Automatic random fade. m.setHoldingTime(4000); // Keep the same color for 4 seconds before fading again. m.setFadingSteps(150); // Fade with 150 steps. m.setFadingSpeed(50); // Each step last 50ms. A complete fade takes 50*150 = 7.5 seconds m.setHSB(random(359), 255, 255) // Random hue mode only change the hue so we first set the saturation and brightness to what we want.}

void loop() { m.tick(); // Update the colors.}

You can also control the speed of the fadings:setHoldingTime(4000) // How many ms do we keep a color before fading to a new one.setFadingSpeed(100) // How many ms between each step when fading.setFadingSteps(50) // How many steps for fading from a color to another.

void setHSB(uint16_t, uint16_t, uint16_t); // Set a fixed color from HSB color space.void setRGB(uint16_t, uint16_t, uint16_t); // Set a fixed color from RGB color space.void setRGB(uint32_t); // Using Color class.void fadeHSB(uint16_t, uint16_t, uint16_t, bool = true); // Fade to a new color (given in HSB color space).void fadeRGB(uint16_t, uint16_t, uint16_t); // Fade to a new color (given in RGB color space).void fadeRGB(uint32_t); // Using Color class.void tick(); // Update colors if needed. (call this in the loop function)void hsb2rgb(uint16_t, uint16_t, uint16_t, uint16_t&, uint16_t&, uint16_t&); // Used internally to convert HSB to RGBbool isFading() // True we are currently fading to a new color.bool isStill() // True if we are not fading to a new color.void setMode(Modes m) // Change the mode.void setHoldingTime(uint16_t t) // How many ms do we keep a color before fading to a new one.void setFadingSpeed(uint16_t t) // How many ms between each step when fading.void setFadingSteps(uint16_t t) // How many steps for fading from a color to another.uint16_t red() // The current red color.uint16_t green() // The current green color.uint16_t blue() // The current blue color.

If you need more explanations, feel free to ask Any remark will be very appreciated !

I've already integrated the pins in the code as well as the analogWrite in the tick function.I've made it optional, if you don't provide pins, it's not a problem. (so it's more flexible)

I've also made some adjustments for fading in HSB space.For example when fading from Hue: 10 to Hue: 350, it won't go up but down.i.e. 10->9->...->0->360->...->350 instead of 10->11->...->349->350.

What is great about this library that I forgot to mention is that there's not a single delay() call.This mean you can use it with a code that can't be interrupted, Ethernet stuff for example.The code uses internal counters and intervals and update when necessary.

Quote from: robtillaart on Today at 03:49:20 PM+ negative(RGB) like the old foto film.Like setRGB but will actually do _r = 255 - r; _b = 255 - b ... ?Don't know the right formula, but it could be simple as that

Quote from: robtillaart on Today at 03:49:20 PM+ setStroboscope(); do a stroboscope while morphing colorsWhat do you mean by "while morphing" ?fading

You can already do a kind of stroboscope like this (careful if you're epileptic smiley-razz)Code:

Hey just a small thing . I'm rusty , i grabbed your library and extracted it in my sketchbook/Libraries/ folderArduino V1.0 opens fine without library error but when I compile your example it does not find RGBMood.h.I use Linux but everything else seems OKWhat could cause this?

Governments should do what they were designed to do only.Manage the larger issues best done by Government.My Family and my Property are no

LucidTronix has a RGB HSB library and a tutorial with sample code. It has a bit packing function which is helpful for driving colors onto 16-bit screens and works just fine for RGB LEDs too. Check it out at http://www.lucidtronix.com/tutorials/19

I use it with 6 differents sets of power RGB leds and your effects are very nice!

For information, my RGB leds are not plugged on pins that provide PWM (pins 2 to 13 on my mega 2560).So I had to include in your library an other library to make PWM using software (softPWM library http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation). I also had to change in your library the "anlogWrite" by "SoftPWMSet".