Is it possible to attach an interrupt to 2 functions according to the mode parameter (RISING or FALLING)?
In fact, with an arduino nano using INT0 (connected to a swith), I would like to detect when my fridge door is being opened and when it is being closed. So will this code work ?
Not on the same pin. Some pins can have a pin change interrupt, that will detect the signal going both ways. But using interrupts for a refrigerator door switch is a serious misapplication of interrupts. Interrupts are for events that must be handled within nanoseconds or microseconds. The software overhead and complexity greatly exceeds what is involved in the normal way of simply polling the switch.
Is it possible to attach an interrupt to 2 functions according to the mode parameter (RISING or FALLING)?
How about triggering the interrupt with CHANGE and detecting which direction the change was in the ISR, or changing the state of a boolean each time an interrupt occurs and using the true/false value to trigger actions. What are these "other actions" that you wish to take ?
However, as has been pointed out, it is very unlikely that you need to use interrupts at all
Thank you for your answers. This is exactly what I was writing after reading the first answer :-)...
That's what I will do..
To answer to the first post : I chose to use interrupts because I thought it would be easier to manage (I also detect if the door of the freezer is opened (on INT1), and I measure the temperature every 2 minuts (well, it's the plan)... Also, I will try the nano to go asleep (I hope it will work better than for my children ) while there is no event, to save the battery...