Fridge Thermostat Software
From Projects
[edit] Version 1
This version was designed for the LM335Z temperature sensor as the DS18B20 was on order for a few days. The text file can be downloaded from File:Fridge-v1.bas.
reset:
input 1
output 2
output 4
let b1 = 0
let w1 = 0
let w2 = 0
main:
let w1 = w1+b1 ' plus 1 if we're on
if w1 = 2880 then reset ' only over 48 hours
let w2 = w2+1 ' Increment the duty cycle counter
if w2 = 2880 then reset ' only over 48 hours
readadc 1,b0 ' Read the temp and send it out
sertxd(#b0,", ")
if b0 <= 138 then fridgeOff ' Do we need to turn the motors on?
if b0 >= 143 then fridgeOn
sertxd(#w1,", ",#w2,", ",#b1,13,10) ' Put out message
let w3 = w2/2
if w3 >= 30 and w1 > w3 then flashSlowFor60 ' flash if duty cycle is greater than 50%
wait 60 ' Wait for a minute
goto main
fridgeOn:
let b1 = 1 ' indicate we're on
sertxd(#w1,", ",#w2,", ",#b1,13,10)
high 2 ' turn on motors
high 4 ' turn on light
if b0 > 144 then flashFastFor60 ' flash fast if hot!
let w3 = w2/2
if w3 >= 5 and w1 > w3 then flashSlowFor60 ' flash if duty cycle is greater than 50%
wait 60
goto main
fridgeOff:
let b1 = 0 ' indicate we're off
sertxd(#w1,", ",#w2,", ",#b1,13,10)
low 2 ' turn on motors
low 4 ' turn on light
wait 60
goto main
flashSlowFor60: ' flash 0.5Hz for 60 seconds
for b0 = 1 to 30
wait 1
high 4
wait 1
low 4
next
low 4
goto main
flashFastFor60: ' flash 1Hz for 60 seconds
for b0 = 0 to 120
pause 250
high 4
pause 250
low 4
next
low 4
goto main