As-is, it's no more risky than any other AC project.
Adapting that circuit (or a similar circuit) for the Arduino could be VERY RISKY! You have to electrically isolate the low-voltage Arduino (and the user) from the AC power (usually optically) and you have to isolate the phase-detection circuit (optically or with a transformer)
I've made a phase-controlled incandescent light dimmer (a long time ago with a different microcontroller) and in my research I've noticed that motor-speed controllers use a different circuit from a light dimmer. Sorry, I don't know exactly what the difference is... It does use the same principal. I've also noticed that a fan speed controller that you buy from a home improvement store is a different product from a light dimmer.
another method i`m trying is to use relay to switch speed, but i cannot find any working example. that way i have to use 3 relay to control a fan.
If your ceiling fan has a 3-way speed-switch, you should be able to "reverse engineer it" and replace the switch with a relay (or maybe two).
If it's actually 2-speeds plus "off", it might simply have a diode. (A diode cuts-off the power for half the AC cycle.) I think my ceiling fans may only have high, low, and of. But, I'm not at home right now and I don't remember...
I've used a diode as a high-low light dimmer (and for a heating pad that was too hot), but I have NOT tried a diode with a motor. It's not a recommendation or suggestion, it's just a guess about how they might be doing it.
If a diode works, you'd need two relays. One to bypass the diode, and one to turn the fan on & off. If you try a diode, do it at your own risk! Don't blame me if the motor overheats and your house burns-down!
Need to know whether the fan motor is a universal brush type , or a synchronous induction type.
Triac phase control will work on brush type motors, but not on induction motors.
The yard blower I was using this afternoon is a universal brush type, but let me assure you that ceiling fans are capacitor-run induction ("squirrel cage") non-synchronous motors.
And in fact, the compact wall controls for ceiling fans are exactly TRIAC phase control devices, with components chosen to work satisfactorily with the particular load. They should not be used in bedrooms as the phase control causes a buzz.
Hi, adding a speed control, to a 240Vac or what ever your mains supply is, can be a problem if the fan has not had a control before.
Fans are designed for particular applications, slowing a fan down not only quietens it and slows the air flow, it can also decrease its electrical efficiency.
That is the motor will get hotter due to the type of control and the fact that the air flow around it has been reduced.
If your fan does not have a control, then don't try and fit one, unless you can be sure that the same fan has been produced with a speed control.
My ceiling fan already have a triac regulator to control the fan, what I want is to control that regulator through my arduino so that I dont have to manually change the speed, that way I dont have to interfere with my fan working.