So basically I want to build a dimmer circuit. If I connect an optocoupler to the PWM pin on the MCU and a triac to the optocoupler with an incandescent bulb and generate a square wave something like this:
In the above example I was using 80% brightness. So basically, the mains frequency is 50Hz and so the generated square wave would be 100Hz with 80% duty cycle. How well would this work ?