As a followup to this question, I would like to figure out how exactly one might go about driving a TRIAC from a microcontroller (for low-voltage applications, such as 24VAC). Imagine a scenario where I've got a low-voltage AC source running a simple switch-mode power supply that supplies my microcontroller. Is it as simple as hooking a GPIO pin to the TRIAC gate and driving the GPIO high (3.3V in this particular case)? Assume I'm using a simple, cheap, and common (apparently) MAC97 TRIAC. Do I need a resistor on the GPIO pin? Does the TRIAC gate conduct current, or is it like a MOSFET gate? If it conducts current, where does it conduct to (the only other two connections are to the AC line)?

Note that I'm not working with mains voltage here; this is for driving low-voltage AC solenoids. I understand that when working with mains voltage that extreme caution is advised and experimentation can be deadly.

  • 2
    \$\begingroup\$ Write the 24 VAC in your question. They think you are dealing with 120 VAC. \$\endgroup\$
    – Telaclavo
    Commented Apr 17, 2012 at 23:25

2 Answers 2


Playing with mains can lead to death of drive equipment, load, TRIAC, yourself or users if you get it wrong.

Try hard not to.

Use of an isolated driver IC greatly enhances the chances of you and your drive electronics living much longer. Anything driving mains equipment directly is potentially at mains potential at any time unless you have a properly implemented isolation barrier. This applies to equipment in EITHER mains lead. Being in the "neutral" lead is no guarantee of not experiencing full mains potential.It also applies to any part of the equipment even when "switched off". Only removal from mains by physical disconnection is a certain means of mains not being absent. Then you just have storage capacitors to watch for.

Drive is from gate to main terminal 1.
As MT1 is at mains potential your driver is too.

You CAN drive directly if your port MINIMUM drive current at gate MINIMUM voltage meets gate MAXIMUM current need. The gate to MT1 is a silicon junction (or two) and requires a minimum (or greater) current to trigger the coupler reliably. A TRIAC conducts AC bidirectionally once triggered and continues to do so until the holding current in MT1-MT2 main circuit drops below some data sheet defined level.

You are very very very very strongly advised to use an isolated driver such as the
MOC30xx family optical TRIAC driver. This is a random turn on version that triggers the TRIAC when you trigger the opto coupler but you can get zero crossing versions. The driver comes in various versisons and needs as little as 5 mA or as much as 30 mA max to trigger - see data sheet page 3.

Here is a Fairchild FOD410 zero crossing optocoupled TRIAC driver.

Circuits below are examples only - see data sheet:

enter image description here

Lower voltages:

For a lower voltage- eg 24 VAC, the personal safety aspects are much relaxed, but the microcontroller safety aspects are still a significant consideration.

When (not if) the small TRIAC shown dies due to enthusiastic experimentation or an excess of exposure to reality, one of the failure modes will be worst-possible-input-hard-shorted-to-worst-possible-output. Murphy loves these. Connecting 24 VAC to almost anywhere on an Arduino will usually spoil its day.

An opto-coupled TRIAC driver will both provide protection against worst case TRIAC failure and also allow "floating" TRIAC drive - the opto-coupler ouput is not ground referenced or referenced to anything in the drive circuit before the OPTO COUPLER.

  • \$\begingroup\$ What's the role of the 360Ohm resistance in the second example? \$\endgroup\$
    – m.Alin
    Commented Apr 18, 2012 at 0:49
  • \$\begingroup\$ @m.Alin - The 360 ohm resistor "spreads" the discharge of the 0.05 uF into the TRIAC gate. This extends the firing pulse, limits the gate surge current which is also the opto coupler output surge current. As the 0.05 uF cap can be charged to a good fraction of mains voltage it is arguably useful to help the opto and TRIAC gate stay alive. \$\endgroup\$
    – Russell McMahon
    Commented Apr 18, 2012 at 2:43
  • 1
    \$\begingroup\$ Does the answer change when I'm working with 24VAC instead of mains voltage? \$\endgroup\$
    – Mark
    Commented Apr 18, 2012 at 13:49
  • \$\begingroup\$ @Mark - see addition to answer re 24 VAC. \$\endgroup\$
    – Russell McMahon
    Commented Apr 18, 2012 at 16:42
  • \$\begingroup\$ This application note finally properly explained to me whats going on in this switching circuit fairchildsemi.com/an/AN/AN-3004.pdf For example, where do the 180 ohm resistors come from , and why there is no Rgt here. \$\endgroup\$
    – kert
    Commented Oct 27, 2013 at 16:32

Assuming your neutral is always wired correctly and there are no ground faults and Neutral voltage drop on every outlet was near the ideal of Zero volts so it is the same as where it is grounded outside at the transformer feed, and no lightning ground surges and common noise ferrite and RC noise snubbers or more expensive polyprop cap snubber, then you have a good chance of not FRYING your development board with the 2 diode drop Gate voltage to the triac. But wise students will learn that opto-isolated triacs are cheap now and should not have to learn what it feels like to make a misteak ! and feel the surge of line voltage in their veins. . THese guys have more stock than Wall Street and ship same day on VISA if called before 8pm cst. I believe. YOu can call them free with Google Voice.

So my best answer is "opto triac" or/and "SSR" or "solid state (opto) relay" in your favorite search engine. No need to re-invent the wheel thinking its cheaper to use discrete triacs.

WHen you get good at EMC and Power Line immunity and safety, you can use the four cent MAC97A6,116 types directly to your floating double insulated DC controller.

  • \$\begingroup\$ You could also use a pulse transformer or wind your own with a small torroid and have the same isolation capability. And a pulse transformer gives you more/better firing options as well. \$\endgroup\$
    – akohlsmith
    Commented Apr 17, 2012 at 23:56
  • \$\begingroup\$ How to protect against backpropogation of HV spikes on torroid transformer ? \$\endgroup\$ Commented Apr 18, 2012 at 6:18
  • \$\begingroup\$ So, without isolation, there are just too many things that can/will go wrong? Even with low voltages? \$\endgroup\$
    – Mark
    Commented Apr 18, 2012 at 13:49
  • \$\begingroup\$ @sandundhammika TVS, high voltage cap, the usual ways. \$\endgroup\$
    – akohlsmith
    Commented Apr 18, 2012 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.