#include <LEDFader.h>

/*
  Fades a single LED up and down using LED Fader.
  Connect an LED to pin 3
*/

//#define LED_PIN 3

#define FADE_TIME 2000

#define DIR_UP 1
#define DIR_DOWN -1

LEDFader led;
LEDFader led1;
LEDFader led2;
int direction = DIR_UP;

void setup() {
  led = LEDFader(1);
  led1 = LEDFader(2);
  led2 = LEDFader(3);
  led.fade(255, FADE_TIME);
  led1.fade(255, FADE_TIME);
  led2.fade(255, FADE_TIME);
}

void loop() {
  led.update();
  led1.update();
  led2.update();

  // LED no longer fading, switch direction
  if (!led.is_fading()) {

    // Fade down
    if (direction == DIR_UP) {
      led.fade(0, FADE_TIME);
      direction = DIR_DOWN;
    }
    // Fade up
    else {
      led.fade(255, FADE_TIME);
      direction = DIR_UP;
    }
  }
   // LED no longer fading, switch direction
  if (!led1.is_fading()) {

    // Fade down
    if (direction == DIR_UP) {
      led1.fade(0, FADE_TIME);
      direction = DIR_DOWN;
    }
    // Fade up
    else {
      led1.fade(255, FADE_TIME);
      direction = DIR_UP;
    }
  }
   // LED no longer fading, switch direction
  if (!led2.is_fading()) {

    // Fade down
    if (direction == DIR_UP) {
      led2.fade(0, FADE_TIME);
      direction = DIR_DOWN;
    }
    // Fade up
    else {
      led2.fade(255, FADE_TIME);
      direction = DIR_UP;
    }
  }
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT