My first attempt was pairing the Arduino board to one of the relays while running the blink LED script. I was unaware that the Uno couldn't delay for 15 mins.
millis() and delay() use milliseconds stored in an unsigned long. That means a maximum value of 0xFFFFFFFF milliseconds which equals 49 days. You should not have trouble creating a delay of 15 minutes.
Below code should do what you want; timing not 100% accurate but close. Currently testing but that takes long ;). Note that this will only work properly if switching the relay on and off is the only thing that you want to do (else you must start using millis() and calculate if durations (15 minutes and 45 minutes) have passed).
// define relay pin
int relaypin = 13;
// initial output low
// set pin mode to output
// initialize serial communication
// some debug
printTime("relay on at: ");
// set pin high
// delay 15 minutes
// some debug
printTime("relay off at: ");
// set pin low
// delay 45 minutes
// function to get hours, minutes and seconds from millis()
// h: pointer to variable to store hours
// m: pointer to variable to store minutes
// s: pointer to variable to store seconds
// milliseconds since program started
unsigned long getDuration(int *h, int *m, int *s)
// get milliseconds since program started
unsigned long ms = millis();
// calculate seconds, minutes and hours
*s = ms / 1000;
*m = ms / 1000 / 60;
*h = ms / 1000 / 60 / 60;
// function to send formatted time (duration) over the serial line
// initial character string
void printTime(char *ptr)
// variables for time information
unsigned long ms;
// buffer for serial output text (max 63 characters plus '\0')
// get duration that program has been running
ms = getDuration(&hours, & minutes, & seconds);
// place in text buffer for serial output
sprintf(buffer, "%d:%02d:%02d (total %lu ms)", hours, minutes, seconds, ms);
// feedback to user
The code does a little more than simply switching on and off; this is for debugging purposes. You can remove it from the loop function when no longer needed.
There are two additional unctions; getDuration gets the hours, minutes and seconds since the program has been running and printTime sends formatted information to the serial monitor.
There is a bug in getDuration; after an hour, it gives 1 for the hour, 60 for the minutes (should be 0) and 3600 for the seconds (should be 0). No time to fix (need to go shopping with the lady); probably should have used modulo (%) instead of division (/).
Note that this bug does not effect the switching of the relay.