Controlling Triac by Arduino

PaulS:
The amount of dimming you get from a triac is based on the time after the zero-crossing event occurs that you trigger the output. Short time == little dimming. Long time == lots of dimming.

Which means you have to detect the AC zero-crossing. It's usually easier to detect only the positive-going zero-crossing. At 50Hz, you know the negative-going zero-crossing is comming 10 milliseconds later.

I built a dimmer several years ago with a different microcontroller, so I can only give you some hints & concepts -

The most important thing is isolation. You need to isolate yourself and the Arduino from the AC line voltage. There are [u]special optoisolators[/u] designed to drive TRIACS. Do NOT get a "zero-crossing" optoisolator. It won't work as a dimmer.

You'll also need to isolate your phase detection (zero crossing) circuit. For that, you can use a "regular" optoisolator, or a transformer. (In my circuit, I used the same transformer that was powering my microcontroller.)

[u]Wikipedia[/u] has a little animation showing how a phase-controlled AC dimmer works with a TRIAC.