Set Firing Angle TRIAC using optocoupler with PWM

Also in that blurred out part you have a direct connection to one side of the mains!

That could be fatal, don't do it.