Good morning...newbie alert...fresh meat!!!! ![]()
I am designing a lighting system that will simulate the sun and moon. Don't know if it will go over and aquarium or aquaponics bed yet. I'm new to Arduino but not to astronomical computing.
void loop() {
while ((now - last_time) < 1000 ){ // set to 60000 for 1 minute
now = millis();
double now1 = now / 10000;
double last_time = now1; // prepare for next loop
}
float Lat = 44.654392;
float LatR = .779366;
float TD = 57.295780;
float TR = .017453;
//46 STEP 2
double dSb = 172;
double dSb1 = dSb + last_time;
double D1 = (2021 - 2010) * 365.242189;
double D2 = D1 + dSb1;
Serial.print("dSb ");
Serial.println(dSb, 8);
Serial.print("dSb1 = ");
Serial.println(dSb1, 8);
Serial.print("Days since 2010 epoch: ");
Serial.println(D2, 8);
//46 STEP 3
double ND = (360/365.242189) * D2;
First, I'm telling the arduino to pause for roughly 1 second (I know there are better ways and have a couple RTC's on order).
Then my latitude in degrees and radians followed by conversion numbers (radians to degrees = TD) and (degrees to radians = TR).
dSb = days Since beginning of the year...also known as day of the year...range from 1 to 365...172 corresponds to June 21 (Summer Solstice or largest amount of light day of the year)
D1 is the calculation for number of days since 1/1/2010 and this gets added to dSb to give me a total day number (D2).
dSb1 is the problem. When I print to the Serial Monitor...it reports that dSb is 172.00000000 (TRUE) but reports that dSb1 = 0.00000000 (FALSE)????? It should be 172.10000000.........
My end goal, within the bigger code, is to get the code to cycle completely, illuminate the proper LED's according to other calculations, then come back to the top, iterate by say....1 minute (code does NOT reflect this goal at this time) and then recalculate with the new number and illuminate the proper LEDS and repeat...add more...recalculate...light up...repeat......
If I cannot get my variable to iterate properly...the whole thing is shot...a 1 time Willie.
I read another post where a user was doing something similar with solar calculations and the responses only succeeded in confusing me more...it's bad enough that I must jump back and forth between degrees and radians...let alone multiply by 1000000 in one line, divide by 1000000 in another then stand on my head and sing "Freebird" backwards while playing the piccolo just to get 1 variable to calculate properly (*don't try this at home...the fall risk is detrimental to your health as much as playing the piccolo).
Once this is completed, I don't mind sharing my code in totality but as of now...I'm almost 1,700 lines in and am jammed up at the beginning ![]()
Without needing a PhD in C programming...what is the answer to my quandary (please/thank you)?
Sincerely...a noob