MyEngineeringStuffs
Published © GPL3+

Arduino Based AC Voltage Control using Zero Voltage Crossing

Controlling AC voltage means we are trying to control speed of single phase ac motor or trying to control the brightness of incandescent bul

IntermediateFull instructions provided8 hours2,151
Arduino Based AC Voltage Control using Zero Voltage Crossing

Things used in this project

Story

Read more

Code

AC voltage control Source code

Arduino
This is the full source code of the project.
#define triacPulse 10
#define SW 7

int x=0;
void setup(){
   pinMode(2, INPUT);
   digitalWrite(2, INPUT_PULLUP); // pull up
   pinMode(triacPulse, OUTPUT);
   pinMode(SW, INPUT);
   digitalWrite(SW, INPUT_PULLUP);
    }

void loop() {
 
  if (!digitalRead(SW)){ // When the switch is closed
    x=analogRead(A0);
    attachInterrupt(0, acon, FALLING); // attach Interrupt at PIN2
    }  
  else if (digitalRead(SW)){ 
       detachInterrupt(0); // Detach Interrupt
     } 
  } 

void acon()  
   {
    delayMicroseconds((analogRead(A0) * 7) + 200); // read AD0 
    digitalWrite(triacPulse, HIGH);
    delayMicroseconds(50);  //delay 50 uSec on output pulse to turn on triac  
    digitalWrite(triacPulse, LOW);
   } 

Credits

MyEngineeringStuffs

MyEngineeringStuffs

13 projects • 71 followers
I 😍 to help people, students are always FIRST, and Yes👉https://paypal.me/pawanbehera1 you can buy me a COFFEE if U😍 my WORK, NAMASTE 🙏

Comments