const byte inputpin= 11;
const byte led1= 12;
const byte led2= 13;
volatile byte verihazir = 0;
volatile long zamanilk = 0;
volatile long aralik = 0;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(inputpin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(inputpin), baslangic, FALLING);
}
void loop() {
if(verihazir){
if( aralik < 1000) digitalWrite(led1,HIGH);
else if (aralik >1500) digitalWrite(led2,HIGH);
verihazir=0;
attachInterrupt(digitalPinToInterrupt(inputpin), baslangic, FALLING);
}
}
void baslangic() {
zamanilk=millis();
verihazir=0;
attachInterrupt(digitalPinToInterrupt(inputpin), bitis, RISING);
}
void bitis() {
detachInterrupt(digitalPinToInterrupt(inputpin));
aralik= millis()-zamanilk;
verihazir=1;
}