ISR(TIMER1_COMPA_vect){ //comparator match
digitalWrite(GATE1,HIGH); //set TRIAC gate 1 to high
digitalWrite(GATE2,HIGH); //set TRIAC gate 2 to high
TCNT1 = 65536-PULSE; //trigger pulse width
}
ISR(TIMER1_OVF_vect){ //timer1 overflow
digitalWrite(GATE1,LOW); //turn off TRIAC gate 1
digitalWrite(GATE2,LOW); //turn off TRIAC gate 2
TCCR1B = 0x00; //disable timer stopd unintended triggers
}