0

On an Arduino you can have several different interrupt types, two of them being RISING and FALLING. Looking past that RISING is from LOW to HIGH, and FALLING is the opposite, what are the benefits of using one or the other?

To clarify; why would you use a RISING interrupt or a FALLING interrupt?

  • 1
    These are the ways an external IO pin can generate an interrupt. You use rising when you wnat an interrupt when the level on a pin rises from low to high. It is that simple. – Wouter van Ooijen Aug 16 '15 at 10:07
7

Imagine that you have the circuit below:

schematic

simulate this circuit – Schematic created using CircuitLab

Let's say that you wanted to catch the user pressing the button. The input signal will go from high to low, which is a falling edge. So you would use a FALLING interrupt to catch this event. Easy, right?

Now let's say you wanted to catch a user releasing the button instead. This time the inverse is true, so you want to use a RISING interrupt.

You should note that since these interrupts are edge triggered, the simple circuit below would not be ideal. Without any debouncing, there may be several edges to trigger from, resulting in repeated interrupts. Also, given the analogue nature of the design, we can't be sure that the rise / fall times will be fast enough to trigger the edge interrupt. We can get around this by adding a 100nF capacitor across the switch and following by a Schmitt trigger (which I can't find a symbol for in the circuit editor!).

So to answer your question, you use the interrupt that is correct for the event you are trying to catch. The Arduino MCU implements both edges for completeness and flexibility in your design, so if this interrupt was coming from an external IC you have no control over the design of, you can easily match the interrupt to its behaviour without having to add in an inverter.

  • 1
    Very good answer. And of course if you want to detect the switch press and release, you can use a CHANGE interrupt. – Nick Gammon Aug 20 '15 at 20:42
0

Suppose you have a pushbutton that connects Arduino pin to the ground. The pin is also pulled up to VCC (may be internally in Atmega chip, or through external resistor). Now, when the switch is open, Arduino sees HIGH, and when you press the button it sees LOW. If you would like to perform an action when the button is pressed, you would use FALLING interrupt. If you would like to know when the button is released, you would use RISING. There are no general benefits of using one over another.

0

The interrupt will be generated by an external circuit. In many cases, you have the control over the design of the external circuit, and you can choose whether it will be generating low-to-high edges or high-to-low edges. But in some cases you don't have the control over the design of the external circuit which generates the interrupt. Then you have to adapt your firmware code to the interrupt source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy