I have a question about interrupts. Can I use different types of interrupts (RISING, FALLING etc) for two different functions of code to run different scenarios on a single interrupt pin. According to my understanding the programming will choose which function to run depending upon the type of interrupt registered ? Am I thinking right.
Hmm, gonna have to review my code to see how I handled rising or falling. It's on a different computer tho.
If you use CHANGE, in the ISR you can determine the current state of the pin to see what the change was - to HIGH or to LOW.
OP: The use of LOW as the interrupt type has very limited applicability. Typically, it is used only when the need to wake the processor from sleep mode.
Okay, so in the nutshell I cannot use a single hardware pin for different types of interrupts as Nick precisely explained.
in order to accomplish the code I written earlier I have to assign each Interrupt type to different hardware pin to accomplish 4 different types of scenarios.
The need to connect the same source of information to 4 different pins, and use 4 different interrupt handlers is correct.
The assumption that you need 4 different handlers is questionable.
Is there something about detecting whether the CHANGE interrupt happened because the pin went HIGH (a RISING edge happened) or went LOW (a FALLING edge happened) that is difficult? It simply involves looking at the current state of the pin. If it's HIGH, the RISING part of CHANGE happened. If it's LOW, the FALLING part of CHANGE happened.
The three different scenarios are really one with a simple test.
The LOW situation is rarely used, and using it in conjunction with other types of events does not make sense. RISING, FALLING, and CHANGE events aren't registered when the Arduino is asleep, which is the only situation where use of LOW makes sense.
msdhillon:
Okay, so in the nutshell I cannot use a single hardware pin for different types of interrupts as Nick precisely explained.
in order to accomplish the code I written earlier I have to assign each Interrupt type to different hardware pin to accomplish 4 different types of scenarios.
...
Correct me if I am wrong. I am new to programming and learning my way through via forums and study material.
You don't have four hardware pins that support external interrupts on the Uno, so this idea won't fly very well. You have pin change interrupts, but in those you have to work out for yourself which way the pin changed.
As more than one of us has explained, a single CHANGE interrupt should suffice for whatever-it-is you are trying to do.