Appendix G: BASIC Scripts
WebRelay-10 Users Manual
Let b = 5
'variable b will be set to 5
Let d = b + 2
'variable d will be set to 7
Predefined Variables
The following are useful predefined variables for the ControlByWeb™ BASIC interpreter. These are
useful for accessing internal values and features states.
Note: Some models may not contain digital inputs, analog inputs and/or relays and thus would not have
digital input, analog input and/or relay variables.
Timer Variables
Six timers are available for use in BASIC scripts. They are designated as t0 through t5. Timers can be
set to any positive integer (or 0) by using the LET statement. As soon as a value is assigned to a timer, it
will begin to count down immediately by decrementing one count every 100ms until it reaches zero.
Examples:
Let t3 = 1500
'set timer 3 to 150 seconds
Let t1 = 0
'disable time 1
Relay Variables
The relays can be turned
ON
, turned
OFF
, pulsed, toggled, or read in BASIC scripts. The LET statement
is used to set the relay state. The state options available are:
0 – turn relay off
1 – turn relay on
2 – pulse relay
5 – toggle relay
The pulse time is specified in the
Relays
setup tab. Relays are designated as relay1, relay2, etc., which
correspond to Relay 1, Relay 2, etc.
Examples:
Let relay1 = 1
'turn on relay 1
Let relay2 = 0
'turn off relay 2
Let relay1 = 2
'pulse relay 1
Let relay2 = 5
'toggle relay 2
Let a = relay2
'read the state of relay 2, state will be 0 or 1
Input Variables (WebRelay-10 Plus™ only)
The input states can be read in BASIC scripts. The inputs are designated as input1 and input2.
Example:
Let a = input1
'sets 'a' equal to value of input 1
Temperature/Humidity Sensor Variables (WebRelay-10 Plus™ only)
Each temperature sensor or humidity sensor can be read in BASIC scripts. The sensors are designated
as temp1, temp2 ... temp8
Example:
If temp2 >= 80 Then 'If temperature sensor reads greater than 80
' degrees, then
Let relay2 = 1
'Turn on relay 2
End If
page 98
Xytronix Research & Design, Inc.