Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define triacPin 3
- #define POT A2
- #define ZCD 1
- int x = 0;
- void setup() {
- pinMode(ZCD, INPUT_PULLUP);
- pinMode(A0, INPUT);
- pinMode(triacPin, OUTPUT);
- }
- void loop() {
- int y = analogRead(A0);
- x = map(y, 0, 1024, 200, 7200);
- attachInterrupt(0, ISR_F, FALLING); // attach Interrupt at PIN2
- }
- void ISR_F()
- {
- delayMicroseconds(x);
- digitalWrite(triacPin, HIGH);
- delayMicroseconds(50);
- digitalWrite(triacPin, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement