int capture;
#define BTN_PIN 2
void setup() {
// put your setup code here, to run once:
TIMSK1 |= (1<<ICIE1);
TCCR1A &= (~(1<<WGM10)) & (~(1<<WGM11));
TCCR1B &= (~(1<<WGM12)) & (~(1<<WGM13));
TCCR1B |= (1<<CS12) | (1<<CS10);
TCCR1B &= (~(1<<CS11));
TCNT1=0;
TCCR1B|=(0<<ICES1); //FALLING EDGE TRIGGER INTERRUPT;
pinMode(BTN_PIN, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("capture");
Serial.print('\n');
}
void loop() {
}
ISR(TIMER1_CAPT_vect) // this isr routine stats with falling edge interrupt
{
capture = ICR1;
Serial.println(capture);
Serial.print('\n');
}