Okay, I'm new to arduino I have done the basic stuff, with an LCD.
I have setup a relay to control a light, I would like to have that light come on at a certain hour. I can tell it to turn on with a delay and turn off.
Seconds to hours or seconds to minutes to hours etc.
I'm not sure how to go about this, the arduino will be on 24/7 powered by a wall adapter. Any help would be great.
The lcd just displays light is on/ light is off
No problems with basic code.
edit I looked at Timealarm is what I want to do, I'm surprised no one had that remark to try it :P
So basically you want the current time?
Arduino's timer isn't very accurate. So, if you want to have a reliable timer, get a RTC chip to go along.
So, the basics:
1 second = 1000 mseconds
1 minute = 60 seconds
1 hour = 60 minutes = 3600 seconds.
1 day = 24 hours
But you allready knew that, right? So all you have to do, is write a program that will count this time variables. For example, I wrote this small example some time ago (before finding the time library)
if (millis() - _timer_start2 > (_timer_interval2))
A simple timer function
if (millis() - _timer_start > _timer_interval)
@kryptek, good to hear you found the timeAlarm library. The TimeAlarm example sketch in the time library download should be close to what you want to do.
@Odisej, the biggest advantage of an RTC is that it keeps time when the arduino board is switched off. A standard Arduino board is quite accurate, as are clones that use a crystal for the system clock.
btw, the code posted above can lose time because it does not take into account delays that occur between the time an exact second has elapsed and the call to simple_Clock to recalculate the next timer interval. Small delays will accumulate over time and a delay of more than a second betwen calls will not be handled correctly.