Page 1 of 1

Moonlight slope using Moon phase monring and night

Posted: Sun May 27, 2012 4:04 pm
by carlii
I have two of the dimmable moonlights in the two PWM channels on my Relay box. I want them to come on from 8 until 10 at night and again from 7 am to 9am. I tried coding a PWM slope with the Moonphase calculation. Is this possible? This is what I tried.

ReefAngel.PWM.SetActinic(PWMSlope(20,0,9,0,MoonPhase,0,120,MoonPhase));
ReefAngel.PWM.SetDayLight(PWMSlope(20,0,9,0,MoonPhase,0,120,MoonPhase));



This was my original code but the lights never cutoff even when I use the setup code:

// Set Actinic and Daylight off by default
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);

This was in my loop code.

if ( hour() >= 20 && hour () <= 22 ) // Moonlights on from 8:00PM to 10PM
{

ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}

else

if ( hour() >= 7 && hour () <= 9 ) // Moonlights on from 7:00AM to 9AM
{

ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}

I really like the idea of a slope from the moonphase and back up again.

Re: Moonlight slope using Moon phase monring and night

Posted: Sun May 27, 2012 4:19 pm
by rimai
Your first code was almost there.
You need this:

Code: Select all

  if ( hour() >= 20 && hour () <= 22 ) // Moonlights on from 8:00PM to 10PM
  {

    ReefAngel.PWM.SetActinic(MoonPhase());
    ReefAngel.PWM.SetDaylight(MoonPhase());
  }
  else if ( hour() >= 7 && hour () <= 9 ) // Moonlights on from 7:00AM to 9AM
  {

    ReefAngel.PWM.SetActinic(MoonPhase());
    ReefAngel.PWM.SetDaylight(MoonPhase());
  }
  else
  {
    ReefAngel.PWM.SetActinic(0);
    ReefAngel.PWM.SetDaylight(0); 
  }

Re: Moonlight slope using Moon phase monring and night

Posted: Tue May 29, 2012 9:47 pm
by carlii
Something is wrong. The lights just stay on all night.

Re: Moonlight slope using Moon phase monring and night

Posted: Tue May 29, 2012 10:09 pm
by rimai
I think I created a bug on the previous libraries release.
Can you use the update utility and upload your code again?