// Einspeisewechselrichter // Nulldurchgang int nulldurchgangspin = A5; bool nulldurchgang; bool nulldurchgangvorher; bool nulldurchgangflanke; #define EXTINT0 2 // Testpins int ledpin = 13; int testpin =12; void setup() { pinMode(ledpin,OUTPUT); pinMode(testpin,OUTPUT); pinMode(EXTINT0,INPUT); attachInterrupt(digitalPinToInterrupt(EXTINT0), EXTINT0_ISR, FALLING); } volatile bool test; void EXTINT0_ISR() { test = true; } void loop() { nulldurchgang = (analogRead(nulldurchgangspin) < 40); //digitalWrite(ledpin, nulldurchgang); // Flanke nulldurchgangflanke = ((nulldurchgang != nulldurchgangvorher) && (nulldurchgangvorher == LOW)); nulldurchgangvorher = nulldurchgang; digitalWrite(ledpin, nulldurchgangflanke); digitalWrite(testpin, test); }