Newbie needs little help (please)

I'm a newbie when it comes to programing. Been doing a lot of reading, but the more i read the more i get confused.
I need a little help understanding this part of my sketch. Mainly the time part. What i was trying to do is simplify it. Simple off / on with the calculation. But every time I think I got it... it won't turn off or it displays the wrong (% format). The correct format is (0.00 %) but when making changes it goes to (00 %). It does work now, it ramps up till midnight - then ramps down from midnight. Just looks more complicated then it should be.

float lunarCycle = moonPhase(now.year(), now.month(), now.day()); //get a value for the lunar cycle
float moon_out = 0.0; //declare the floating point version of blue intensity

if ( ((now.hour() == 3) && (now.minute() < 45)) || (now.hour() < 3)) // Off at 3:45 am.
{
moon_out = moonled_out * ((((float)now.hour() - 22) + ((float)now.minute() / 42)) / 3);
}
else if (now.hour() > 16)
{
moon_out = moonled_out * ((((float)now.hour() - 17) + ((float)now.minute() / 42)) / 3);
}
moonled_out = MoonLow *(1 - lunarCycle) +
MI * lunarCycle + .5;
analogWrite(moon, moon_out);

You left out the part that does the formatting. I am going to guess that the problem is in line 42. :smiley: We want to see all of your code, not just a snippet!

Please post your code in code tags (the # button).

Could I just paste it, Or how do I add the code to the reply? I'll have to do it later this evening.

It's the '#' button to add code in the bulletin board code format, or you could just,

[code]Paste your code inside here[/code]

HI, okay now, brief description, what are you trying to do in your sketch?
What are the inputs, what are the outputs, display etc.
Looks like you are indicating phases of the moon, but a description of how please.
When you wrote this sketch did you start it stage by stage, getting somethings to work then adding etc.
Or did you try and write it all at once.
If you are having display format problems, then just write a display sketch on its own using your hardware and experiment with variable types to get it right.
Then go back to your developing sketch and add what you have found.
For a newbie it seems an awful big sketch.
Tom.......... :slight_smile:

Ok, This started out as someone else's sketch (Numlock10) from reef central. I added the time alarms, switched over to (RTClib.H)--my brother said it was better, but I don't know if it is or not & I didn't really like his moon phase part. I tested and found that this moon phase i'm using now is pretty accurate (close) and a little easier to adjust.
Currently everything works correctly, but what I was trying to do is simplify the on / off times for the moon phase - like I mentioned in my first post. That's when I start having issues like not displaying the moon % format correctly or the moon led won't turn off. Oh, And yes i'm a newbie. I'm lost. :~ My brother helped me add the time alarms, but he doesn't know much about the arduino. Or that could be his way of blowing me off?

Nobody? :frowning: