0% found this document useful (0 votes)
47 views3 pages

This Is The Code For Ac Dimmer Using Arduino Board. To Watch It'S Full Tutorial Video, Head On To My Youtube Channel

This document contains code for an Arduino AC dimmer circuit. It uses an Arduino board, a triac, and potentiometer to vary the brightness of an AC load. The code initializes pins for the triac, potentiometer and switch. It reads the potentiometer to determine the firing angle of the triac, attaching an interrupt triggered on zero voltage crossings to pulse the triac at the calculated time.

Uploaded by

Javier Guerrero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views3 pages

This Is The Code For Ac Dimmer Using Arduino Board. To Watch It'S Full Tutorial Video, Head On To My Youtube Channel

This document contains code for an Arduino AC dimmer circuit. It uses an Arduino board, a triac, and potentiometer to vary the brightness of an AC load. The code initializes pins for the triac, potentiometer and switch. It reads the potentiometer to determine the firing angle of the triac, attaching an interrupt triggered on zero voltage crossings to pulse the triac at the calculated time.

Uploaded by

Javier Guerrero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*

* This is the code for AC Dimmer using Arduino Board.

* To watch it's full tutorial video, head on to my YouTube Channel

* http://www.youtube.com/techiesms

*/

#define triacPulse 10

#define SW 7

#define ZVC 2

int x = 0;

void setup() {

Serial.begin(115200);

pinMode(ZVC, INPUT_PULLUP);

//digitalWrite(2, INPUT_PULLUP); // pull up

pinMode(A0, INPUT);

pinMode(triacPulse, OUTPUT);

pinMode(SW, INPUT);

digitalWrite(SW, INPUT_PULLUP);

}
void loop() {

//if (!digitalRead(SW))

{ // When the switch is closed

int y = analogRead(A0);

x= map(y,0,1024, 200,7200);

Serial.println(digitalRead(ZVC));

attachInterrupt(0, acon, FALLING); // attach Interrupt at PIN2

//else if (digitalRead(SW)) {

//detachInterrupt(0); // Detach Interrupt

//}

void acon()

// Serial.println("REad");

delayMicroseconds(x); // read AD0

digitalWrite(triacPulse, HIGH);

// Serial.println(digitalRead(triacPulse));

delayMicroseconds(50); //delay 50 uSec on output pulse to turn on triac

digitalWrite(triacPulse, LOW);

// Serial.println(digitalRead(triacPulse));
}

You might also like