Dios 'Stove Fan Program func main() gconst ontemp 99 gconst offtemp 97 gconst onhot 150 gconst offhot 145 dim clickcount as integer dim clickflag as integer clickcount = 0 clickflag = 0 output 3,7,8,12,13,14 low 3,7,8,12,13,14 dim celsius as float dim fahrenheit as float DS1620init(0,1,2) '--------------------------------------------- 'Main loop '--------------------------------------------- again: celsius = DS1620readtemp(0,1,2) fahrenheit = CelsiustoF(celsius) print {-0.1} celsius,"c ",fahrenheit,"f" '========================================= 'Check to see if its warm enough to turn ' On fan '========================================= if fahrenheit > ontemp then Relayon() LEDon() clickcount = 0 endif if fahrenheit < offtemp then Relayoff() LEDoff() if clickcount < 10 then clickcount = clickcount + 1 click() endif endif '===================================== 'Check to see if its too hot '===================================== if fahrenheit > onhot then sirenon() endif if fahrenheit < offhot then sirenoff() endif toggle 7 ' heartbeat pause 1000 goto again endfunc func Relayon() high 3 endfunc func Relayoff() low 3 endfunc func LEDon() high 12 low 13 endfunc func LEDoff() low 12 low 13 endfunc func sirenon() high 14 endfunc func sirenoff() low 14 endfunc func click() sirenon() pause 50 sirenoff() endfunc include \lib\Dios1620.lib