Help for TRIAC strange behavior
If you want phase control, you can't use a zero-crossing optocoupler. They are designed to prevent phase control to minimize switching noise (EMI). Try a MOC3052-M instead. You will need to lower R3 significantly to get 10 mA. And don't aim for just 10, aim for 15 or more. My version of Jasen's quote -- aim between the goal posts (great quote, I may borrow it) is when margin is cheap, put in a lot. 

Edit: Glitch issue: Put the optocoupler input on the scope at the same time. If the trigger pulse from the MCU extends into the next half-cycle, the next half-cycle will be full.

Make sure that your MCU zero-cross detector is not sensitive to noise. The AC input (mains) can have a tremendous amount of noise on it, your design needs to deal with this. This can be done in hardware or software.