From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi Guys! Does anyone know how I can make my code simple? (See attached code)

Solved!
Go to solution

My goal is to turn LED ON and OFF automatically every time I change the number in the input field (CONTROL).

I mean I am able to do it with my code. I kind of feel like there has to be a simple way to do this. 

Can you please share your code or idea?

P.S: If you think the way I do this is the best and simplest way, let me know too. 

Thanks!

See attached VI.

P.S: Event structure is excluded.

0 Kudos
Message 1 of 6
(966 Views)

As always, your code is just plain silly!

 

  • Having a hidden array control to serve as an empty array is pointless
  • inserting a scalar into a empty array, then indexing out that element just returns the original value? Why all that extra code?
  • Your local variables are read way before the terminals are written, they will most likely always be equal. Race condition!
  • How are you planning to ever stop the loop?
  • ...

 

 

0 Kudos
Message 2 of 6
(946 Views)

@GRCK5000 wrote:

My goal is to turn LED ON and OFF automatically every time I change the number in the input field (CONTROL).

 


What does that even mean?

 

  • Change the LED to the opposite whenever the value changes?
  • Change the LED to TRUE for a limited amount of time for every change in the control? For how long?
0 Kudos
Message 3 of 6
(942 Views)
Solution
Accepted by GRCK5000

If you look in the comparison palette, there is this function. You could use it.

(NOTE: It will also trigger on first call).

 

Alternatively, you could make your own, e.g. as follows:

(NOTE: This will not trigger on first call)

 

altenbach_0-1653777139493.png

 

Message 4 of 6
(938 Views)

Thanks Mr. Altenbach for the feedback. This will help me work hard on improving my code and understanding better what I am doing.

0 Kudos
Message 5 of 6
(848 Views)

This is so simple. I think so hard for no reason. smh

0 Kudos
Message 6 of 6
(841 Views)