'{$STAMP BS2}


'Program 1.2; Simple Heater

LED1 VAR OUT4
RC CON 7
Temp VAR Word

OUTPUT 4
LED1 = 1

Main:
GOSUB ReadTemp
GOSUB CheckTemp
PAUSE 250
GOTO Main

Readtemp
HIGH RC
PAUSE 10
RCTIME RC, 1,Temp
TEMP = TEMP/30

DEBUG "Temp = ",DEC Temp, CR
RETURN

Checktemp:

IF (temp > 100) OR  (LED1 = 1) THEN checkoff
LED1 = 1
DEBUG "The heater energized", CR

Checkoff:
IF (temp < 120) OR (LED1 = 0)THEN checkdone
LED1 = 0
DEBUG "The heater de-energized", CR
Checkdone:
RETURN