const int VOL_PIN0 = A0; const int VOL_PIN1 = A1; const int VOL_PIN2 = A2; void setup() { attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt to suit board model pinMode(3, OUTPUT); // GATE control pinMode(4, OUTPUT); // OUT GATE control } //the interrupt function must take no parameters and return nothing void zero_crosss_int() //function to be fired at the zero crossing { int value; float delay0; // Wait after zero cross trigger value = analogRead( VOL_PIN0 ); delay0 = value ; int value2; float ontime1; // On time value2 = analogRead( VOL_PIN1 ); ontime1 = map(value2, 0, 1023, 0, 100); int value3; float ontime2; // On time discharging value3 = analogRead( VOL_PIN2 ); ontime2 = map(value3, 0, 1023, 0, 2000); digitalWrite(4,HIGH); //set In GATE to high delayMicroseconds(ontime1); // On time digitalWrite(4,LOW); //turn off gate delayMicroseconds(delay0); // Wait digitalWrite(3,HIGH); //set OUT GATE to high delayMicroseconds(ontime2); // On time digitalWrite(3,LOW); //turn off gate } void loop() { }