I have 4 if conditions associated with a variable called ValveActive (changing from 1 to 4) inside a program loop which executes every second. Each if condition is true for 5 minutes. Inside each if condition I need to set a boolean PortSetto true for a defined amount of time and then set it false. I would like the process of turning on the boolean not to repeat when the loop repeats. The boolean represents turning on a relay and then turning it off, something that I would like to happen only once during the duration of each unique ValveActivestate.
Start of loop
If ValveActive=1
PortSet(9,1) 'Activate port
'Do something
Delay (1,25,mSec)
PortSet(9,0) 'Deactivate port
ElseIf ValveActive=2
PortSet(9,1)
'Do something
Delay (1,25,mSec)
PortSet(9,0)
ElseIf ValveActive=3
PortSet(9,1)
'Do something
Delay (1,25,mSec)
PortSet(9,0)
Else
PortSet(9,1)
'Do something
Delay (1,25,mSec)
PortSet(9,0)
EndIf
Loop
I have experiemnted with setting up a boolean to outside the loop to false then turning it to true inside the loop but this does not work for multiple if conditions. How can I achieve this?
Aucun commentaire:
Enregistrer un commentaire