unsigned long t_f;
unsigned long t_r;
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
Serial1.println("Hello, Raspberry Pi Pico!");
pinMode(16, INPUT_PULLUP);
attachInterrupt(0, isr_f, FALLING);
attachInterrupt(0, isr_r, RISING);
}
void isr_f(void){
t_f = millis();
t_r = 0;
}
void isr_r(void){
t_f = 0;
t_r = millis();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
Serial1.print(t_f);
Serial1.print(" - ");
Serial1.print(t_r);
Serial1.print(" = ");
Serial1.println(t_r - t_f);
}