1
Technical support / Re: TBASIC Input On/Off Question
« on: December 10, 2019, 02:46:24 PM »
Thank you all for your help. I am posting this in case someone needs help in the future with this. Here is the final code I wrote that works exactly like I wanted:
rem 'First clear the value for GrndrTmr
TIMERPV[9] = -1
CLRIO GrndrTmr
Refresh
rem 'Determine if the switch is on (High) or off (Low) and set the timer value
IF TestIO(SWHigh)
Then SetTimerSV 9, GetTimerSV(15)
Else
SetTimerSV 9, GetTimerSV(16)
ENDIF
RETURN
This code, along with the ladder I attached, allows you to have a timer that you can change based on if a switch is on or off.
rem 'First clear the value for GrndrTmr
TIMERPV[9] = -1
CLRIO GrndrTmr
Refresh
rem 'Determine if the switch is on (High) or off (Low) and set the timer value
IF TestIO(SWHigh)
Then SetTimerSV 9, GetTimerSV(15)
Else
SetTimerSV 9, GetTimerSV(16)
ENDIF
RETURN
This code, along with the ladder I attached, allows you to have a timer that you can change based on if a switch is on or off.