Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; picaxe 08m2 ; brain
- setfreq m4 ; 4mhz clock
- symbol DS18B20_pin = C.4 ;dallas pin
- symbol control_pin = C.2 ; pot pin
- symbol relay1 = C.1 ; fan relay pin 120v :O
- LOW relay1
- symbol Sw1 = C.3 ; switching pin
- pullup %00000010 ; internal pullop C.1 for switch
- symbol minutes_pause = 1 ; delay 1 minute for subroutine
- main:
- readtemp DS18B20_PIN, w1 ; read sensor value into w1
- w1 = w2 * 9 / 5 + 32 ; convert to farenhieght
- readadc10 control_pin, w2 ; use adc to read 10k pot into w1
- w2 = w2 / 8 ; makes a value from 0 - 127 cool trick this
- sertxd ("+" , #w1 , " degrees DS18B20 ") ; to terminal
- sertxd (#w2, " pot setting " ,13, 10) ; to terminal
- if Sw1 = 0 then goto heater_on
- ; air conditioner on
- ; power on if DS18B20 (w1) >= pot (w2)
- ; this assumes the AC is on
- if w1 >= w2 then relay_on1
- LOW relay1
- gosub wait_here
- goto main
- heater_on : ; function
- ; power on if DS18B20 (w1) <= pot (w2)
- ; this assumes pellet stove is running and we can use it to warm pipes
- if w1 <= w2 then relay_on1
- LOW relay1
- gosub wait_here
- goto main
- relay_on1 ; function
- HIGH relay1
- gosub wait_here
- goto main
- wait_here: ; function
- for b5 = 1 to minutes_ pause ; 10-second loops
- pause 10000 ; wait 10 seconds
- next b5
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement