# multi channel ac dimmer for arduino

I have been looking for a simple ac dimmer circuit to use with my arduino and/or raspberry pi. I have used the TLC 5940 PWM Driver before just to control LEDs and I wanted to adapt this to controlling strings of xmas lights. Since I am just beginning with electronics, I don't wanna blow my face off by doing it wrong. Do you have any suggestions for anything that is not only compact but cost effective???

• My suggestion: don't do it! You're an admitted beginner and there are too many ways to kill yourself working with mains voltage. Jan 7, 2015 at 20:06
• Rephrase...I am a beginner with controlling ac with DC...I have done simple relays before...but nothing with dimmers for ac Jan 7, 2015 at 20:25
• If it's mainly the control part you're interested in, a less dangerous option would be to use 10V DC controlled dimmers, and just build the interface circuit for generating the 0--10V DC control signal. Jan 7, 2015 at 20:28
• I am looking to control Xmas lights...I already have relays for ones that need to just be turned off and on...but I need a circuit for dimming them Jan 7, 2015 at 20:32
• Yes, but unless you really want to build the AC circuit yourself, I suggest that you take a look at off-the-shelf dimmer modules. For modest wattages I think they can be found at reasonable prices, unless you want a massive number of channels. Jan 7, 2015 at 20:43

I've done this before, except I was controlling theater lights at 20A per channel. Here's how I did it:

simulate this circuit – Schematic created using CircuitLab

• R1 sets the current through the LED side of the isolator, just like you're used to.
• R2 limits the current to what the isolator is rated for, but it's only needed while the power triac is in the process of turning on. Use something that can handle the full line voltage and a decent amount of power, but it should barely get warm.
• L1 limits dI/dt through the triac to match its rating. You can go bigger to reduce EMI, but not too big or it becomes difficult to turn the circuit off. More on that later.
• R4 has a similar function as R1.
• You can share the same Zero-Crossing detector for all channels. Keep in mind that the pulse width is not zero, so you'll need to find the center and use that.

The theory of operation is:

1. Wait for zero-crossing
2. Turn PWM off
3. Wait for desired off-time
4. Turn PWM on
5. Repeat

You can do this in parallel for as many channels as you have hardware and processing time for. I always bit-banged it with interrupts while the main loop handled communications.

The PWM must be synchronized with the AC power line because the triac latches on until the current stops (which it must do every zero crossing, so we're okay there). You technically don't have to hold it on, but it makes the logic easier and removes the requirement for a minimum load.

The latching behavior may also cause a problem for false triggers. If the load is too reactive, including L1, then the triac dropping out may cause enough inductive kick to retrigger it, so it effectively sticks at 100% on.