Thanks @PickyBiker, I got it working with your solution. Also had to introduce some debounce code for the input.
Here's my final code for critique and / or assistance for anyone else with a similar situation. (PS, i still need to clean it up a bit and remove all the serialprint's I was using to assist with debugging.)
#define relayPin 2 // the pin relay is connected
#define triggerPin 3 // the pin where start switch is connected
long triggerTime = 0;
long duration = 300000;
volatile byte relayState;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);// initialize serial monitor with 9600 baud
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);
pinMode(triggerPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(triggerPin), trigger, FALLING);
Serial.println("Routine Begin");
}
void loop() {
// put your main code here, to run repeatedly:
if( (millis() - triggerTime) > duration && relayState == HIGH)
{
controlRelay();
Serial.print("Time - ");
Serial.println(millis() - triggerTime);
triggerTime = 0;
}
else
{
delay(50);
}
}// loop end
void trigger()
{
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
if (interrupt_time - last_interrupt_time > 300)
{
if(relayState == HIGH)
{
controlRelay();
Serial.println("Relay RESET");
triggerTime = 0;
}
else
{
triggerTime = millis();
controlRelay();
Serial.print("Time - ");
Serial.println(triggerTime / 1000);
}
}
last_interrupt_time = interrupt_time;
}// trigger end
void controlRelay()
{
if(relayState == HIGH)
{
digitalWrite(relayPin, LOW);
relayState = LOW;
Serial.println("Relay OFF");
}
else
{
digitalWrite(relayPin, HIGH);
relayState = HIGH;
Serial.println("Relay ON");
}
}