08-26-2022 02:49 AM
In the program attached below, the arm/disarm led will turn on when I press button 2 and will turn off when i press button 3.
This is a prototype program for arming/disarming a vehicle.
I want to modify the program such that when i press button 2/3 for 2 seconds, only then they perform the desired function. if i press for less than 2 seconds, nothing happens.
How can I do that?
08-26-2022 03:24 AM
Hi sarwat,
@sarwatsarfaraz wrote:
In the program attached below,
There is no program, just two images showing parts of your code…
@sarwatsarfaraz wrote:
I want to modify the program such that when i press button 2/3 for 2 seconds, only then they perform the desired function. if i press for less than 2 seconds, nothing happens.
How can I do that?
I recommend to use the event structure in favor of that InputDevice functions.
Then you need to store the timestamp of the "button press" event in a shift register. You can use the timeout event to check for your "minimum 2s delay" and you can also monitor any "button release" events…
08-26-2022 03:51 AM
You should "filter" your button signal. On the rising edge, you should register the switch time. Then, you continuosly check Tnow - Tswitch.
Have a look to the attached code.
08-26-2022 10:21 AM
As a first step, you need to define the problem fully. For example what should happen if both buttons are pressed for 2 seconds?
08-26-2022 10:49 AM
Since you seem to prefer pictures over actual VIs, here's one simple possibility to turn on an LED after the button 2 has been pressed for 2 seconds. No need for local variables and case structures.
You can easily expand it for more buttons and the desired behavior for each once you exactly define the problem.