Thanks for coming

Sharing is Caring
As being pointed out previously, start by syncronizing with the mains wave.
Try Google 'zero crossing detector', and choose a circuit (I would prefer using an OP Amp)
I did it so far
Let interrupt start delay counter to send trigger signal.
Hope this is useful.
Svend
I ever think that method,
I read that on
http://gammon.com.au/interruptsthere some requirement to do that
Keep it short
Don't use delay ()
Don't do serial prints
Make variables shared with the main code volatile
Variables shared with main code may need to be protected by "critical sections" (see below)
Don't try to turn interrupts off or on
As far I know,
If I use that, there two group in my code(code for writing quite long because it control three phase pulse)
Interrupt for reading input(counter), then another to writing pulse.
but if we do interrupt, the main code will wait interrupt disabled.
so it can't run at once.
how you think about that?