AC 220V fan speed control using Arduino/node mcu


I would like to know "How to control triac through Arduino / nodemcu". The basic operation of on/off is done with the help of MOC 3051 (optocoupler) and triac 16A, 600V. Switching action was successful. Now i would like to control the speed of fan through Arduino / nodemcu.

Kindly guide me.

Maybe look at

Sir i wasn't able to understand the firing angle solution for AC control. Can you guide me in that?

What kind of fan is it?
If its an induction motor type fan which are the most common, you cant control the speed with a triac, you need a VFD (variable frequency drive.)

Phase cutting works for resistive loads (incandescent lights, heaters). Not for inductive loads (such as most AC motors).

See e.g. this discussion on how common 3-speed fans are controlled using capacitors.

Some fan motors ( depending on type) can have speed controlled using a series capacitor.

Ceiling fans are one example with values of 1.5uF and 2.5uF giving a low and medium speed.