stephanschulz
Well-known member
I am using attachInterrupt on a teensy 3.2.
Inside my interrupt function I need to know if the CHANGE was due to a pin going HIGH or LOW. Because inside the function then measure the time difference for the HIGH state and LOW state.
Is it ok to do a digitalRead to get the pin state or will that not be accurate as the CHANGE already occurred?
Would it be better to use two attachInterrupt(), one for FALLING and one for RISING?
Thanks for any advice.
Inside my interrupt function I need to know if the CHANGE was due to a pin going HIGH or LOW. Because inside the function then measure the time difference for the HIGH state and LOW state.
Is it ok to do a digitalRead to get the pin state or will that not be accurate as the CHANGE already occurred?
Would it be better to use two attachInterrupt(), one for FALLING and one for RISING?
Thanks for any advice.
Code:
void setup(){
attachInterrupt(digitalPinToInterrupt(HAND_INPUT), handInput_interrupt, CHANGE);
}
void handInput_interrupt() {
pulse = digitalRead(HAND_INPUT);
}