'{$STAMP BS2}

'{$PBASIC 2.0}
'{$PORT COM1}


'Program 1.3; Simple Heater
'Configure StampPlot Lite

PAUSE 500
DEBUG "!Span 50,150",CR
DEBUG "!TMAX 60", CR
DEBUG "!PNTS 500", CR
DEBUG "TITL Simple Heater Control", CR
DEBUG "!Shift ON",CR
DEBUG "!TSMP ON",CR
DEBUG"!Plot ON",CR
DEBUG "!RESET",CR

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 DEC Temp,CR
DEBUG IBIN LED1,CR

DEBUG "Temp = ",DEC Temp, CR
RETURN

Checktemp:

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

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