Can I attach more than on handler to a interupt pin?

attachInterrupt, can I attach more than one handler? The ideal way is check to get current handler attached, and then attachInterrupt to my own handler and at then end of my handler, I can call the original handler.

Why would you want to?

An Arduino can only do one thing at a time.

...R

Robin2:
Why would you want to?

An Arduino can only do one thing at a time.

...R

My board now installed with RCSwitchFirmata, it can handle RC signals. I want it to handle other signal like those from acurite temp sensor.

wyx2001:
My board now installed with RCSwitchFirmata, it can handle RC signals. I want it to handle other signal like those from acurite temp sensor.

You need to provide a lot more information. Describe the project you are trying to create.

What is RCSwitchFirmata?
What do you mean by RC signals?

Why would you need an interrupt to deal with a temperature sensor? Temperatures usually change slowly.

Posting your program would be a big help.

...R

attachInterrupt takes a pointer to a function and saves it. It can then be used as a callback function.

If you give attachInterrupt a new pointer it will not keep the old one, there is room for just one pointer value per pin, so one callback function's address can be registered per pin.

Since attachInterrupt() takes a pointer to a function, you could write a function to get the currently registered pointer, or NULL if there is no registered function. Then, you could register your function. Before your function ends, you could then call the previously registered function.

Not that this would necessarily be easy, mind you, but it could be done.

If you were adventurous, you could even change the process to have a list of pointers to functions, for each interrupt. Attaching a handler would simply add the pointer to the list. Detaching a handler would simply remove the pointer from the list. When an interrupt happened, each handler in the list would be called, in the order registered.

Not that I would do something like that, but it IS possible.

Or just attach a function that calls both the functions you want to attach to it...

DrAzzy:
Or just attach a function that calls both the functions you want to attach to it...

If you know what the currently attached function is, that would work. If you don't, well there's a creek, a boat, and no paddle.

PaulS:
If you know what the currently attached function is,

Why wouldn't you?

...R

When the callback is run interrupts will be disabled so I think the best advice is to keep it as short and simple as possible, in other words, set a flag (or some such thing) and let the interrupt finish. Then look for the flag in the main loop and do whatever jobs are needed from there (I think that is the correct advice).

Why wouldn't you?

Do you know what every library you use does? Most users here do not. A library could attach an interrupt handler, and most people wouldn't know.

PaulS:
Do you know what every library you use does? Most users here do not. A library could attach an interrupt handler, and most people wouldn't know.

I have been foolishly assuming that this Thread is about interrupt handlers that the OP has created.

...R