moon program question

eddiesylas

Premium Member
I am attempting to use "moon.h" from https://github.com/reefangel/Libraries/blob/master/Moon/Moon.h
and "MoonPhase()" from their "Global" file. For the following code I wrote to implement these:
Code:
#include "Arduino.h"
#include "TimeLib.h"                //https://github.com/PaulStoffregen/Time 
#include "Wire.h"
#include "DS1307RTC.h"
#include "Moon.h"
#include "General.h"                    //See Post below for explination

#define pinMin 0                            // PWM min
#define pinMax 255                          // PWM max

/*||||||||||||||||||||  Moon Light  ||||||||||||||||||||||||||||*/

float moonPhase;
float aa;

const int moonLED = 8;         // Light Connected to digital pin (pwm)

void setup() {

    Serial.begin(9600);
    Wire.begin();
    setSyncProvider(RTC.get);
    lcd.begin(20, 4);

analogWrite(moonLED, pinMin);   
}

void loop() {
{
moon_init(10,-86); // pass it lat / lon - it uses ints for the caclulation in moon.h

if (Moon.isRise) {
    moonPhase = (MoonPhase());
    } 
  else {
    moonPhase = (0);
    }
        unsigned long moonPhotoPeriod = (set_time - rise_time);
        aa = (sin((moonPhotoPeriod - now()) / moonPhotoPeriod * PI));
        double bb= pow (moonPhase , 3);
        double cc = pow (moonPhase , 16);
        bb = ((bb + cc) / 2);
        float dd = (aa * bb);
        
        int moonIntencity = (pinMax * dd);
     
analogWrite(moonLED, moonIntencity);
  }
 delay (1000);
}

For the line:
Code:
unsigned long moonPhotoPeriod = (set_time - rise_time);
I don't know how to call:
Code:
time_t rise_time, set_time;
in "moon.h" or even if it is the correct call to make to determine a sin() wave length.

RA forum states to use:
Code:
ReefAngel.PWM.SetDaylight(PWMSlope(Moon.riseH,Moon.riseM,Moon.setH,Moon.setM, 0,MoonPhase(),30,0));
But I don't know what "slope( , , )" is or what type of function it is nor how to use it.

Suggestions?
 
Back
Top