Go Down

Topic: Using interrupt buttons for different tasks at different parts of code (Read 272 times) previous topic - next topic


Hello all,

I am trying to write a program for a product that would have:


My MainProgram has a timer which based on user input(push button) calculates result in real-time, therefore the user input (push buttons) i have wired to interrupt pins (UNO 2,3) , pushing the button interrupts MainProgram to add user input and update display, then continues with MainProgram.

What i would like to achieve is - to use the same buttons on interrupt pins (2,3) to perform different action in previous SetupScreen menu, but since button on interrupt pin is called from outside void_loop() using void pin_ISR1/2 im a bit stuck on trying to figure out how to achieve that.

also another problem with timer already running while still in SetupScreen, but that is different topic :)

thanks for any help


nvm, i had the idea of putting IFS inside void pin_ISR to check on which var MENU program is currently is and to act accordingly, think this should solve it


There's no reason to use processor interrupts for capturing user button inputs. Properly-written, non-blocking code can easily handle it though polling.


thanks for the tip, since im quite new - the term polling is also new to me, ill look into it!

the properly-written , non-blocking part will be the challenge ;))



Since you're using buttons, somewhere along the way, you'll likely need to know when a switch undergoes a change of state .

In the IDE:  File/examples/digital/state change
Everything we call real is made of things that cannot be regarded as real.  If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet. - Niels Bohr

No private consultations undertaken!

Go Up