Moonlight slope using Moon phase monring and night

Do you have a question on how to do something.
Ask in here.
Post Reply
carlii
Posts: 84
Joined: Sat Mar 17, 2012 7:22 pm

Moonlight slope using Moon phase monring and night

Post 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.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Moonlight slope using Moon phase monring and night

Post 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); 
  }
Roberto.
carlii
Posts: 84
Joined: Sat Mar 17, 2012 7:22 pm

Re: Moonlight slope using Moon phase monring and night

Post by carlii »

Something is wrong. The lights just stay on all night.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Moonlight slope using Moon phase monring and night

Post by rimai »

I think I created a bug on the previous libraries release.
Can you use the update utility and upload your code again?
Roberto.
Post Reply