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: 

how to program a loop to switch on or off

Solved!
Go to solution

Hi all

 

I have the same code in two while loops controlling four LEDs. I am using a case structure in each loop to switch two conditions (condition A and condition B).

 

Condition A switches on LED 1  in the first loop and LED 2 in the second

Condition B sitchecs on LED 3 in the first loop and LED 4 in the second.

 

Each case selector receives a numeric value from a waveform.

 

Ok, here is what I would ideally like to achieve.

 

Have an On/Off button (or similar) wired to the loop condition terminal of both loops

If the button is on, loop 1 stops and loop 2 runs. 

If the button if off, loop 2 stops and loop one restarts...i.e I want the button to switch on and off the loops with the program running

 

Thanks

Greg

 

 

0 Kudos
Message 1 of 4
(3,652 Views)

What you want is a single while loop with a single case structure inside.  A shift register will tell you which case will run on each iteration.

0 Kudos
Message 2 of 4
(3,638 Views)
Solution
Accepted by topic author GregFlynn
You can't do what you want unless there is a larger structure around the whole thing, but it is easier to just do what RavensFan advises. Unless there is more to the problem than what you have told us, its easier to have one loop that does two things than two loops that do one thing each.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 4
(3,623 Views)

Thanks all

 

Im sure what you said ravensfan is the simpliest, but I kinda have the hang of case structures so I went with your suggestion Mike. 

 

Thanks again

 

I am pretty new to Labview, but I have to say, this forum is the business....class

0 Kudos
Message 4 of 4
(3,560 Views)