help with push button

I am trying to modify the following code. What I want to do is add a pushbutton to my controller to switch on the opto coupler which then control’s a triac, which is from digital pin 9. I want the triac to stop on for 1 hour then switch off and carry on in normal mode. I can only get it working momentarily, it will not stop on for 1 hour. From what I can understand about the code is that it takes mains readings 100 times over 1 mains cycle. any help would be appreciated.

code attached.

Mk2_PV_Router.ino (19.7 KB)

        // then set the Arduino's output pin accordingly, 
        digitalWrite(outputPinForTrigger, nextStateOfTriac);

Can be changed to:

        if (inDelay)
            {
            // then set the Arduino's output pin accordingly, 
            digitalWrite(outputPinForTrigger, ON);
            if (millis() - delayStartTime > 60UL*60UL*1000UL)  // Been in delay for an hour
                inDelay = false;
            }
        else
            {  
            // then set the Arduino's output pin accordingly, 
            digitalWrite(outputPinForTrigger, nextStateOfTriac);
            }

To start the delay, set inDelay to true and set delayStartTime to millis().

I i have tried using a delay and it doesnt work. I forgot to mention before the opto coupler only fires on zero crossing so for it to work it needs to be fired 50 times a second. I think i need a loop within the main loop so when the button is pressed this loop fires the trigger 50 times a second for 1 hour