Where did you find that code? It doesn't look like standard Arduino sketch.
Your sketch is not too hard to do:
const uint8_t relayPin = 10; // change to whatever pin you connected the relay to
const bool relayOn = HIGH; // you may need to invert these two values, depending if
const bool relayOff = LOW; // your relay is Active Low or Active High
void setup()
{
pinMode( relayPin, OUTPUT );
// step 1: turn on relay for 15 seconds
digitalWrite( relayPin, relayOn );
delay( 15000 );
}
void loop()
{
// step 2: turn off relay for 90 minutes
digitalWrite( relayPin, relayOff );
delay( 5400000 );
// step 3: turn on relay for 10 seconds
digitalWrite( relayPin, relayOn );
delay( 10000 );
}
That's it, basically. But, it's ugly, and can be made much better using the technique shown in the Blink Without Delay example and combine with nilton61's suggestion of a state machine
For your suggestion on a simpler script, i really need the first "15 seconds" to be outside of the loop.. As i may have to adjust the initial "on-time" depending on situations
I thought of using DELAY... But from what i read... Delay function is unreliable and not accurary ( although i dont need really accurary time.. Deviation from 2-3a is ok)
But would the 90mins (long) interval delays be an issue? Especially in a looping
If you use my State machine library you can write your code with a perfect 1:1 relation between states and state function. Also non blocking timing is built in so the need for delay is eliminated.
#include <SM.h>
const int relayPin = 8;
const unsigned long InitDelay = 15*1000;
const unsigned long OffDelay = 90*60*1000;
const unsigned long OnDelay = 10*1000;
SM relayTimer(Init);
void setup(){
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, 1);//turn relay on at start
}//setup()
void loop(){
EXEC(relayTimer);
}//loop()
State Init(){
if(relayTimer.Timeout(InitDelay)){
digitalWrite(relayPin, 0);
relayTimer.Set(off);
}//if(Timeout)
}//Init()
State on(){
if(relayTimer.Timeout(OnDelay)){
digitalWrite(relayPin, 0);
relayTimer.Set(off);
}//if(Timeout)
}//on()
State off(){
if(relayTimer.Timeout(OffDelay)){
digitalWrite(relayPin, 1);
relayTimer.Set(on);
}//if(timeout)
}//off()
Yes it was a mistake, I moved the step 1 in setup, so only step 2 and 3 will loop forever.
delay is pretty accurate, from my tests, but I admit I never tried with a delay of more than one minute. My guess would be something like +/- 1 second per hour, but I can be wrong.
I habitually recommend to NOT use delay, but in simples cases like yours, it's just the easiest solution.