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?