Without going into software details I can see a suspicious voltage divider:R1 and R2 ..
Q1 suppose to deliver pulses to the microcontroller on zero-crossing but as it is now (r1=330Ω, r2=33Ω) it won’t probably do it..
hi IanP
thanks for reply
now with this value (r1=330,r2=33) i can see zero crossing in oscilloscope but in pd.4 always is 1 (portd.4=1) & don't reset to turn on diod in moc3021
i think that program code have a problem but i can not solve it