Go Down

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

ejmoska

Hello all,

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

WelcomeScreen;
SetupScreen;
MainProgram;

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

ejmoska

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

gfvalvo

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

ejmoska

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 ;))

gfvalvo


dougp

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
So two neutrinos went into a bar.  Nothing happened.  They were just passing through.

Go Up