Go Down

Topic: design project with DS1307 (Read 545 times) previous topic - next topic

NEMD

hey guys

I'm a total beginner in arduino, in fact i only just heard about it and started using it within the last month.

i'm using a DS1307 real time clock and i have successfully managed to input time and it reads it etc. I did this based on all your posts, searching playground, tutorials and examples.

My problem is actually setting an alarm time. I'm really struggling to find a code to follow and my plan is to set 2 alarm times based on 1 alarm time...

My goal is to set an alarm time using set potentiometer ranges; e.g turning  a set pot range to set the alarm for 6am. (this is an extra element tho)

My priority: once this time has been set, i want it to count backwards 9 hours and set off a different alarm e.g. once 6am has been set, an alarm signal must go off at 9pm.

has anyone got any ideas as to how i might code this up?? Is it even do able??

many thanks

wortelsoft

You could use the millis command:

http://arduino.cc/en/Reference/Millis

Its's just a mather of doing some smart maths.

you set the start time to variable.
Then in a loop check if the alarm time is due and then do your stuf.
 
some code whithout correct syntax, but you should be able to get it.

starttime = millis()

while (alarmtime  > millis() - starttime)
   wait for it
loop
Start the alarm bells

check this, it's a lot better then my attemp above:

http://arduino.cc/en/Tutorial/BlinkWithoutDelay

Go Up