FadLed timing

I am using the FadeLed library to fade three LEDS and I want each led to fade up and down in sequence

I tried using millis() timing shown in my attached sketch but I cannot get the timing to work out exactly and as time progresses the leds start to overlap each other.

Is there a way to trigger the next led in sequence using leds.done or some other trigger.



I am using the FadeLed library

That you got as a blue light special at KMart?

I don't understand your reply but the FadeLeds library is in the ARDUINO PLAYGROUND at "Arduino Playground - FadeLed "

There is a typo in my original post leds .done should be leds.done.

I would really appreciate some help.



The program you posted is a bit cluttered with stuff. But if you want to fade 3 leds in sync you can use the .done() and .getCurrent() methods pretty easy.

But “fade up and down in sequence” is still a bit vague. Do you want to first fade up and down the red led and start the Green when the red turned off etc? And fade red up again once the white turned off again?

I think this should do that:

#include <FadeLed.h>

FadeLed leds[] = {9, 10, 11};
const byte NrLeds = sizeof(leds)/sizeof(leds[0]);

byte currentLed = 0;

void setup() {
  //for now I set them all to fade in 2 seconds (constant speed mode)
  for(byte i = 0; i < NrLeds; i++){
  //and I start fading the first

void loop() {
  //if done fading up
  if(leds[currentLed].done() && leds[currentLed].get()){
    //fade down again
  //if done fading down
  else if(leds[currentLed].done() && !leds[currentLed].get()){
    //go to next led
    if(currentLed >= NrLeds){
      currentLed = 0;
    //and start fading that

Untested though :stuck_out_tongue:


Thank you, it works perfectly.
My code was really cluttered before I cleaned it up and posted it; I was going around in circles and getting deeper in confusion the more I tried.
Thank you again.


I know the feeling. Sometimes it's just easier to trow everything in the bin and start fresh. That way you really know what you want instead of bolting code to a so-and-so-base :slight_smile:

Good it works!