Hi again.
What is the proper way to make use of multiple states using switches, based on time?
What I mean is - say you press button1, it's associated IO pin sinks current via a resistor to ground, I can detect this and make a subroutine execute. But what if I want a different routine to execute if that pin is held to gnd for more than 2 seconds and yet a 3rd routine if it's held for 5 seconds?
Do you pass timing to the next loop? ie start a timer after first detection and check again at intervals? But then doesn't that change the logic for all button checking code? You now have to process based on leading edge of the switch release and not the press/sink?
I am confusing myself. Am I on the right track?
What is the proper way to make use of multiple states using switches, based on time?
What I mean is - say you press button1, it's associated IO pin sinks current via a resistor to ground, I can detect this and make a subroutine execute. But what if I want a different routine to execute if that pin is held to gnd for more than 2 seconds and yet a 3rd routine if it's held for 5 seconds?
Do you pass timing to the next loop? ie start a timer after first detection and check again at intervals? But then doesn't that change the logic for all button checking code? You now have to process based on leading edge of the switch release and not the press/sink?
I am confusing myself. Am I on the right track?