Download Eagles files from GitHub: https://github.com/ForceTronics/AC-Switch-Proto-Board
*********************************Arduino code shown in the video********
//This sketch is used to control Thyristor that is used as a switch to turn on and off an AC line powered light. //This code is free for all to use
int8_t dig = 0; //default is high for light off
void setup() {
//for controlling Thyristor
pinMode(7, OUTPUT); //set pin to output so it can sink current from optoisolator
digitalWrite(7, HIGH); //when high the thyristor is off or open
}
void loop() {
delay(3000); //light turns on / off every 2 seconds
togLight(); //call function to turn light on / off using digital pin
}
void togLight() {
if(dig) {
digitalWrite(7, HIGH); //turn off light
dig = 0; //toggle dig value
}
else {
digitalWrite(7, LOW); //turn light on
dig = 1;
}
}
No comments:
Post a Comment