12-01-2010 01:37 PM
Hi, I'm very confused by, what it looks, very simple task.
I have a piece of code and I need to plug it to "start" button which will execute it once when button is pressed, execute once again if I press the button again and so on.
I tried with "while" loop and true/false button connected to it but, as you know, code inside the loop executes itself continously as long it's true which is incorrect, it doesn't stop when it should.
I woul'd like it like that: Press start->code in block executes once and thats it, no more unsless I press the button again..
Please advice.
ps: I attached piece of vi I need to connect with button. It actually works as inteded but I fail to make it executable with button.
Solved! Go to Solution.
12-01-2010 03:26 PM
You should surround your code with an event case structure in a loop, with the case being value change of your front panel control.
12-01-2010 03:34 PM
An event loop is the way to go but since you're a beginner; this is the basic, simple way:
You need to right-click the button and change the mechanical action to latch when pressed (or released) to run just once. If you set it to switch it will toggle.
12-01-2010 03:38 PM - edited 12-01-2010 03:39 PM
Very simple. See the attached code. I've added a loop, case structure, run button, and stop button.
Edit: My code is exactly what Niquist published. Remarkable.
12-01-2010 04:06 PM
@tbob wrote:
Very simple. See the attached code. I've added a loop, case structure, run button, and stop button.
Edit: My code is exactly what Niquist published. Remarkable.
Great minds think alike, tbob!
12-02-2010 12:52 AM - edited 12-02-2010 12:52 AM
05-16-2011 03:33 AM
Please, Can you post this VI in LabVIEW 2009??
Thanks
05-16-2011 03:40 AM
Here you go, 2009 version. note that one file is missing.