Zero crossing detection

taurian:

I got my dimmer working.
I'm using Arduino Mega 1280.
Here is my code, hope You understand

I do not know much is still setting the timers. when it detects the interruption timer reset to zero right?

thank Gil

Yes, at every interrupt it sets counter to zero and starts again counting up from 0 to 255 (in reality it is 1 to 216 or smth near this number and 216 is full OFF and 1 is full ON).
If counter value is same as I requested with requestValue, it sets output high and triac holds itself up until the end of half period.