I have a DS1302 and i wanted to set a specific time in the rtc, (eg. 15:30:0), and after that i want the program to run itself at that specific time. how do I set the time n call the function for the program? Will d code below works?
#include<DS1302.h>
//set pins for rtc
DS1302 rtc (6, 7, 8 );
void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// Setup Serial connection
Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(6, 8, 2014); // Set the date to August 6th, 2014
}
Really makes no sense to me that, seems like it is missing some parts...
Anyways, I am using a DS1307 in my project, just to log the time and date for when things occur.
For your project, I assume you basically are after a way to schedule something to happen on a specific time and date?
I would simply use the example code for the DS1302 to set the time to the current time today, and then in the void loop() make a simple check to see if the date from the RTC matches the date you want something to run, and then call the function for it.
It seems you are trying to set the time on the RTC to august 4th 2014 and that's it... Sorry if I misunderstand and also apologies if the DS1307 and DS1302 aren't doing the same things...
I use that exact sketch when mine needs to be set.... just put the code a few minutes fast and upload. Then a second or so before the time in the sketch, hit reset on the Arduino and then because the sketch re-starts, that time gets set and stays there (long as you have power of course.)
I made one change to that sketch, to set write protect to true when it had finished setting the time.
Then in my other sketch, the "real" one, I read the time.
luddiluddludde:
Really makes no sense to me that, seems like it is missing some parts...
Anyways, I am using a DS1307 in my project, just to log the time and date for when things occur.
For your project, I assume you basically are after a way to schedule something to happen on a specific time and date?
I would simply use the example code for the DS1302 to set the time to the current time today, and then in the void loop() make a simple check to see if the date from the RTC matches the date you want something to run, and then call the function for it.
It seems you are trying to set the time on the RTC to august 4th 2014 and that's it... Sorry if I misunderstand and also apologies if the DS1307 and DS1302 aren't doing the same things...
yes basically it's scheduling something to happen. To be in details, i wish to set a specific time for my mouse cursor to move automatically. I have done the programming for the mouse to move, but d problem is the scheduling. Can u tell me which example should i use to modify? because it seems like all d examples were set to show d date n time, whereas i don need it for my project. Anyways, thanks for ur help.