Go Down

Topic: Drive a 230VAC Lamp from a TRIAC with Arduino (Read 2093 times) previous topic - next topic


Hi to all, i've read something about TRIAC and i tried to drive a 230VAC Lamp with it in order to change the intensity with arduino.
First of all i have tried a circuit with only a 5V battery with a variable resistance connected to the gate of the TRIAC.
It worked well. From 4 to 5 V the Lamp light intensity changed a lot.
After that, i've tried to use an Atmega328U with a minimal circuit and i wrote this simple code:

  analogWrite(gatePin, val); //100-255
  val = val+sign;
  if(val == 255)
  if(val == 255 || val == 100)
    sign = -sign;

to have the gatePin fluctuating between about 4 and 5V.
When i connected the 230VAC, the gate of the triac went from 4V to about 1-2V and the Atmega became hot (it burned  :~).
So i've tried to add a diode of non return (As you can see in the attachment).
When i connected the 230VAC the gate of the triac jumped to an high value of voltage (i think over 20V) so i disconnected immediatly the main source.

What am i doing wrong?

Thank you



you have to isolate your arduino from the triac by using an optocoupler like MOC3020.
I made some 230vAC lamp controls, but always with a zero detection circuit (TLP620 AC optocoupler): http://forum.arduino.cc/index.php/topic,33490.0.html (sorry, in french)

"pour résoudre un gros problème, il est souvent plus facile de le diviser en petits problèmes élémentaires..."

projet domotique xPLDuino
IRC: freenode #xplduino


if it got hot the pin may have damaged..

use a 1k resistor to the triac.... that should do it, but for safety reasons it's better to use an opto
isolator that way there's no direct path from the 240v supply to the arduino or you..

(but if you wanted to anyway, 1k resistor out to your gate (with the diode if that's all you got), that will stop the arduino getting hot)


Thanks to all. I'll try an optocoupler ;)

Go Up