LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Press and delay button with case structure

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?

Download All
0 Kudos
Message 1 of 5
(954 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(943 Views)

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.

Download All
0 Kudos
Message 3 of 5
(936 Views)

As a first step, you need to define the problem fully. For example what should happen if both buttons are pressed for 2 seconds?

0 Kudos
Message 4 of 5
(889 Views)

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.

 

altenbach_0-1661528982255.png

 

Message 5 of 5
(881 Views)