Sorry if this question is basic, I am pretty new to coding. I am trying to fade 4 different colors of Cree LED's using LDD drivers (http://www.meanwell.com/search/LDD-H/LDD-H-spec.pdf) at different rates and times slowly to simulate sunrise, sunset, etc. I do not want to use delay because I will also have sensors displaying data on a LCD screen. I found the arduino-LEDFader (GitHub - jgillick/arduino-LEDFader: An arduino library to fade individual LEDs in the background without blocking your main program.) library that can fade without delay but I cannot easily find a way to do it over a long period of time. I tried starting with just one color and tried to fade it over 10 minutes but can only get a maximum of about 10 seconds in one command. I figured I could do it incrementally like in the code below; this fades over a minute but could be increased 10X to be over 10 minutes:
#include <LEDFader.h>
/*
Fades a single LED up and down using LED Fader.
Connect an LED to pin 3
*/
#define LED_PIN 11
#define FADE_TIME 10000
#define DIR_UP 1
#define DIR_DOWN -1
LEDFader led;
int direction = DIR_UP;
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
void setup() {
led = LEDFader(LED_PIN);
Serial.begin(57600);
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
}
void loop() {
led.update();
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
if (now.hour() == 13 & now.minute() == 31 & now.second() == 0) {
led.fade(40, FADE_TIME);
}
if (now.hour() == 13 & now.minute() == 31 & now.second() == 10) {
led.fade(80, FADE_TIME);
}
if (now.hour() == 13 & now.minute() == 31 & now.second() == 20) {
led.fade(120, FADE_TIME);
}
if (now.hour() == 13 & now.minute() == 31 & now.second() == 30) {
led.fade(160, FADE_TIME);
}
if (now.hour() == 13 & now.minute() == 31 & now.second() == 40) {
led.fade(200, FADE_TIME);
}
if (now.hour() == 13 & now.minute() == 31 & now.second() == 50) {
led.fade(240, FADE_TIME);
}
}
This is obviously a repetitive way of doing this but cannot figure out a better way to write the code. Can anyone help me with a more condensed method for this code.