Smooth fading of led's at low light

Is it possible to fade led's using PWM smoothly over low light values, about 0-100? I am trying to have a set of 4 Mean Well LDD drivers, for 4 different colors, fade led lights over a long period of time, like 20 min. I have tried using multiple libraries made for fading led's but all are supposed to be done over short periods of time. When trying to modify the examples to fade over a long time I get a stepping effect on the low levels of light, about 0-100.

When posting on the forum for S/W issues it is customary if not mandatory to post the code you are having issues with. Simply announcing you are having problems means nothing to us if you are not willing to take the time to post your code. Do your part and we will try to do ours. It's a two way street. In addition , since you are driving hardware, we will require a schematic (hand-drawn schematic photographed with a cell phone is sufficient) as well as datasheets for the devices (be they leds or whatever).
The only exception is the garden variety red led. No datasheet is required for that.

Sorry, I did not post my code because I don't think the way that I am trying to do it is right and was simply trying to see if it is possible. Anyway here is my code:

#include <LEDFader.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h" //DHT library 


#define LED_PINc 6
#define LED_PINw 9
#define LED_PINb 10
#define LED_PINr 11

#define FADE_TIME 30000

LEDFader ledr;
LEDFader ledb;
LEDFader ledc;
LEDFader ledw;

int r = 15;
int b = 15;
int c = 15;
int w = 15;
int rstep = 10;
int bstep = 10;
int cstep = 10;
int wstep = 10;
int rday = 105;
int bday = 125;
int cday = 125;
int wday = 205;
int rnight = 0;
int bnight = 155;
int cnight = 0;
int wnight = 0;

DHT dht1; // define dht1 as a DHT
DHT dht2; // define dht2 as a DHT

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
int button = 1; //variable for buttons

RTC_DS1307 rtc;
void setup() {
  Serial.begin(57600);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();
  lcd.begin(16, 2);
  lcd.setBacklight(GREEN);
  
  dht1.setup(7); // assign dht1 to pin 2
  dht2.setup(8); // assign dht2 to pin 4
 
 //outlet control 
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW); //pump on
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  
  ledr = LEDFader(LED_PINr);
  ledb = LEDFader(LED_PINb);
  ledc = LEDFader(LED_PINc);
  ledw = LEDFader(LED_PINw);
}

uint8_t i=0;
void loop() {
  DateTime now = rtc.now();
  ledr.update();
  ledb.update();
  ledc.update();
  ledw.update();
  
  dht1.getMinimumSamplingPeriod();
  float humidity = dht1.getHumidity();
  float temperature = dht1.getTemperature();
  //setup dht1
  
  dht2.getMinimumSamplingPeriod();
  float humidity2 = dht2.getHumidity();
  float temperature2 = dht2.getTemperature();
  //setup dht2
  
  uint8_t buttons = lcd.readButtons();

  // LED no longer fading, switch direction
  if (now.hour() >= 8 && now.hour() < 9) {
      if (!ledr.is_fading()) { 
      ledr.fade(r, FADE_TIME);     
      if (r < rday) {
        r = r + rstep;
      }
      ledb.fade(b, FADE_TIME);     
      if (b < bday) {
        b = b + bstep;
      }
      ledc.fade(c, FADE_TIME);     
      if (c < cday) {
        c = c + cstep;
      }
      ledw.fade(w, FADE_TIME);     
      if (w < wday) {
        w = w + wstep;
       }
     }
   }
   if (now.hour() >= 9 && now.hour() < 21) {
     if (!ledw.is_fading()) {
      ledr.fade(rday, FADE_TIME);  
      ledb.fade(bday, FADE_TIME);  
      ledc.fade(cday, FADE_TIME);  
      ledw.fade(wday, FADE_TIME); 
      digitalWrite(2, LOW); 
      }
   }
   if (now.hour() >= 21 && now.hour() < 22) {
     if (!ledr.is_fading()) {
       ledr.fade(r, FADE_TIME);     
      if (r > rnight) {
        r = r - rstep;
      }
      if (b > bnight) {
        b = b - bstep;
      }
      ledc.fade(c, FADE_TIME);     
      if (c > cnight) {
        c = c - cstep;
      }
      ledw.fade(w, FADE_TIME);     
      if (w >wnight) {
        w = w - wstep;
      }
      digitalWrite(2, HIGH);   
    }
   }
   if (now.hour() >= 22 || now.hour() < 8) {
     if (!ledw.is_fading()) {
      ledr.fade(rnight, FADE_TIME);  
      ledb.fade(bnight, FADE_TIME);  
      ledc.fade(cnight, FADE_TIME);  
      ledw.fade(wnight, FADE_TIME); 
      digitalWrite(2, HIGH); 
      }
   }
  
  //turn on outlet 1 if humidity drops below 60%
   if ((humidity + humidity2)/2 <= 70) {
     digitalWrite(5, LOW);
   }
   if ((humidity + humidity2)/2 >= 85) {
     digitalWrite(5, HIGH);
   }
   
   if (buttons) {
    lcd.clear();
    lcd.setCursor(0,0);
      if (buttons & BUTTON_UP) {
      button = 1;
    }
      if (buttons & BUTTON_DOWN) {
      button = 2;
    }
      if (buttons & BUTTON_LEFT) {
      button = 3;
    }
  }
  
  if (button == 1) {
    lcd.setCursor(0,0);
    lcd.print("Temp  #1 ");
    lcd.print(dht1.toFahrenheit(temperature), 1);
    lcd.setCursor(0,1);
    lcd.print("Humidity #1 ");
    lcd.print(humidity, 1);
  } // if up button is pushed show dht1 results
  
  if (button == 2) {
    lcd.setCursor(0,0);
    lcd.print("Temp  #2 ");
    lcd.print(dht2.toFahrenheit(temperature2), 1);
    lcd.setCursor(0,1);
    lcd.print("Humidity #2 ");
    lcd.print(humidity2, 1);
  } // if down button is pushed show dht2 results
  if (button == 3) {
    lcd.setCursor(0, 0);
    lcd.print(now.year(), DEC);
    lcd.print('/');
    lcd.print(now.month(), DEC);
    lcd.print('/');
    lcd.print(now.day(), DEC);
    lcd.setCursor(0, 1);
    lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
  } // if if left button is pushed show time
}

These are the drivers (http://www.meanwell.com/search/LDD-H/LDD-H-spec.pdf) and the leds (http://www.cree.com/LED-Components-and-Modules/Products/XLamp/Discrete-Directional/XLamp-XPG2 as well as Cree XP-G, Cree XP-E, and Cree XT-E). For a schematic I used this image (https://donnie.co/aquarium/arduino-ldd.png) multiplied by 4 (I have 4 LDD drivers for each color) with the drivers connected to pins 6, 9, 10, and 11 on my arduino Uno. On top of that I have a ds1307 RTC clock, a 4 channel relay to control outlets, 2 DHT22 humidity and temperature sensors and an LCD. If you want me to draw a schematic of all of it together I can.

Right now you are only posting for help with the light fading function and we have enough info on that so I think the rest can wait for now. Can you take a video of the current fading performance (no pun intended) and upload it to YOUTUBE and post the link so we know what we are dealing with ? I don't have a DS1307 and have not studied the code here yet:
http://playground.arduino.cc/Code/time#.UzTUP_ldW_g
so can you give us a SITREP (Mil-Speak for Situation Report) on your knowledge and level of experience with the RTC (Library/functions) ? Posting the code doesn't really tell us you know anything and telling you what to do is not nearly as useful as telling how to learn what to do by yourself. (I could tell you how to ride a bicycle but it's not the same experience as doing it.) I could tell you what code to use but that doesn't mean you would know how to do something different with the same chip. So , can you , or can you not , read the RTC and count minutes ? It's a yes or no question. PWM has 255 levels, and there are only 60 minutes in an hour. You have a real time clock that can count seconds, minutes and hours and you are asking us how to fade lights gradually over 20 minutes. Why ? What is wrong with this picture ?

raschemmel:
So , can you , or can you not , read the RTC and count minutes ? It's a yes or no question. PWM has 255 levels, and there are only 60 minutes in an hour. You have a real time clock that can count seconds, minutes and hours and you are asking us how to fade lights gradually over 20 minutes. Why ? What is wrong with this picture ?

If you look at my code I can read the RTC hours, minutes and seconds and I understand that PWM goes from 0-255. My question is if I can make it fade smoothly instead of stepping from one integer to the next.

FYI, here on the forum, people copy and paste code all the time and then come here say "this code is working but I don't know how?" If know how your code is working then more power to you but there is nothing unusual about my question. I just need to know if you know the syntax .

When trying to modify the examples to fade over a long time I get a stepping effect on the low levels of light, about 0-100.

The resolution of the PWM is too coarse. This is a hardware problem because the arduino PWM is integer based. You have to change your hardware and use Mosfets to sink the current and use the PWM to drive the mosfets. That should work. If my I understood you correctly it will never work driving the leds
directly because the PWM is a 0V to 5V signal, whereas a mosfet (they come in many flavors) can vary the current gradually.
You need to start a new post in ELECTRONIC "Looking for N-Channel Mosfet to drive LDD-H LED drivers for smooth FADE"

Check the last line of my last post.

The Meanwell LDD's have an inbuilt PWM dimming circuit so I am not entirely sure that a seperate Mosfet is really required.

I am not familiar with the LEDfader library - I will see if I can find it and have a look at how it works tonight.

I also use LDD's to drive CREE XPG's etc but you are currently restricted to the default Arduino 8 bit PWM. I am currently using one of these Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits to provide 12 bit (4,096 steps) and it works very well.

It might be worth considering.

Maybe have a look here.

I think the way Magicj is doing it looks like the simplest. Sorry if this is a basic question, I am pretty new to electronics but if I buy one of those chips (Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits) do I simply connect the PWM pins on that board directly to the LDD driver PWM wire with no need for an external power supply to the chip? I know it needs the external power to power servos but do the PWM pins need the external power as well or can they just be powered by the 5V from the arduino? Also I was wondering if this product (Adafruit 12-Channel 16-bit PWM LED Driver - SPI Interface [TLC59711] : ID 1455 : $7.50 : Adafruit Industries, Unique & fun DIY electronics and kits) at adafruit would work. It does 16-bit PWM for half the price but it doesn't appear to have a PWM output pin and does it internally. Is there a way to use this to somehow get the 16-bit PWM signal to the drivers? I realize that 16-bit is overkill but if it can be done cheaper why not have more flexibility?