Page 1 of 1

Loop control varibles

Posted: Sat Dec 16, 2006 8:58 am
by sdwx72
Im just wondering if its posible to be able to control a loop with a switch input using a single bit assignment. What I want to do is have a switch input that calls a loop to execute ONLY while the switch is depressed...once i release the switch id like the loop to stop. is this possible?

any help would be great

Posted: Mon Dec 18, 2006 11:35 am
by Benj
It certainly is possible to do that.

Firstly use an input block with the bit you want to test masked. Read this input into a byte variable eg. Bit_Test.

Then use a while block and set the conditions to while Bit_Test

Remember to place an second input block inside the loop to update the Bit_Test variable so that the loop will exit when you stop pressing the switch.