' The below code duplicates the functionality of a basic thermostat. ' If you have any questions, email: support@DataNab.com ' ------------------------------------------------------------------- stpt = 500 ' initialize the stpt to be 50% dbnd = 50 ' set deadband equal to 5 % i = 1 j = 1 10 In1V = iostate(501) ' check state of analog input 1 if In1V > (stpt + (dbnd/2)) then ' if greater than stpt + deadband/2 = 52.5% if i = 1 then ' only do it once IOCTL 1,1 ' turn relay 1 on j = 1 i = 0 endif else ' otherwise if In1V < (stpt - (dbnd/2)) then ' if less than stpt - deadband/2 = 47.5% if j = 1 then ' only do it once IOCTL 1,0 ' turn relay 1 off i = 1 j = 0 endif endif endif goto 10 ' repeat from 10 END