noInterrupts();

Hi :slight_smile:

Is it possible to enable and disable interrupts(); only for one pin?

Best regards

You can use attachInterrupt() and detachInterrupt() on any pin that supports interrupts. So, to answer your question, yes. You can read up on interrupts here:

https://docs.particle.io/reference/device-os/firmware/photon/#interrupts

3 Likes

Yes, I already know :slight_smile:

But how can I disable/enable interrupts only for a specific pin and not for the whole Particle? (because when I do this I get problems with uploading the code). When I call noInterrupts(); I disable interrupts for all pins.

If you want to disable the interrupt for just one pin, call detachInterrupt() for that pin. You can call that anywhere in your code. When you want the interrupt back, call attachInterrupt() again. Using noInterrupts() is a sledge hammer approach to disable all interrupts as you already know (usually for a block of code that needs to not be interrupted for critical timing purposes). The attach/detach methods are more granular. Does that answer it? Unless I fail to see your point or root cause of your question?!?

4 Likes