Difficulty using interrupts to recreate the spark socket in a dimmer switch[SOLVED]

Ah, well your Spark Core is still going to be out of sync with your AC, even if your frequency is the matched. I would think if you are off by a few Hertz in frequency, because of the asynchronous timing you will see the “beat frequency” (your freq. - AC freq). However if you increase your frequency to a multiple higher than the frequency you are chopping, you will have a high beat frequency that will be imperceivable to the human eye.

It looks like you may be using the interrupt with a zero crossing detector? If so try this for your timing:

// 60Hz timing
digitalWrite(AC_pin, HIGH);      // turn triac ON
delayMicroseconds(65*(dim));     // delay for ON time (takes up to 
digitalWrite(AC_pin, LOW);       // turn triac OFF
delayMicroseconds(65*(255-dim)); // delay for OFF time

Also speed up your mapping:
dim = analogRead(sensorPin)/16; // instead of dim = map(sensorValue, 0, 4095, 0, 255);

:smile: