# control AC fan speed using microcontroller

I have been trying for a long time to digitally control the fan speed and light intensity of a dimmable LED bulb, but I am not able to. Basically I want to replace the mechanical potentiometer with a digitally controlled resistance. I have tried every possible dimming solution.

1. Replacing the mechanical pot with LDR and varying its resistance by illuminating it with LED in closed tube. It's not at all a good & stable solution and the arrangement is difficult to replicate (the output fluctuates greatly).(commercially available solution is very costly)

2. Cutting a portion of AC waves by detecting zero crossing with the help of a micro (ATTiny). It gives a flickering output when a dimmable LED bulb is used.