5

Hi I have a simple VI to press a button to turn on the led. My code works just fine except I would like to have the button to be back to normal color after pressing. I tried all the mechanical actions, but none of them does what I want it to do.

The procedure is as follows:

  1. Say before user presses the button it appears like this enter image description here
  2. After user presses the button it becomes enter image description here
  3. Then the led turns on
  4. Once it executes the event the button goes back to enter image description here

The block diagram is shown below: enter image description here

I am puzzled and could someone please help me ?

user1296153
  • 575
  • 6
  • 23
  • 1
    This question is essentially a duplicate of this one: https://stackoverflow.com/questions/49442778/labview-button-freezes-after-pressed-once Different symptom, same root cause. I’m recording the relationship between the two questions to aid future searches. – srm Mar 23 '18 at 18:21

1 Answers1

6

The reason the Latch mechanical action isn't working for you is that a Value Change Event on a Latched Boolean will not trigger its mechanical action. In order to trigger the mechanical action, you have to read directly off the Boolean terminal on the block diagram. This is explained in the LabVIEW Help under "Using Events with Latched Boolean Controls".

If you want the boolean to latch, make sure its set to the Latching mechanical action, and then use the actual terminals value to turn the boolean indicator on/off rather than a constant. I've also added a Case Structure to the OK Button to ensure the boolean indicator is only updated when the "OK Button" is enabled.

Here's a VI Snippet showing the latch in action.

enter image description here

shmicah
  • 413
  • 2
  • 13
  • 1
    I'll repeat what shmicah said in slightly different words: the value of a latched boolean resets when it is read. – srm Jan 31 '18 at 05:13
  • 1
    To be precise (@srm and I are the Thompson Twins): when its value is read from its terminal, but not any other way (local variable, Value property node, event structure `NewVal` terminal, etc.) – nekomatic Feb 01 '18 at 21:13