Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; brain
- ; picaxe 08m2
- 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
- symbol MINUTES_PAUSE = 1 ; delay 1 minute for subroutine
- LOW RELAY1
- symbol SW1 = pinC.3 ; switching pin
- pullup %00001000 ; internal pullup pinC.1 for switch
- symbol temperature = w1
- symbol temp_set = w2
- symbol loop_counter = b5
- main:
- readtemp DS18B20_PIN, temperature ; read sensor value into w1
- temperature = temperature * 9 / 5 + 32 ; convert to farenhieght
- readadc10 CONTROL_PIN, temp_set ; use adc to read 10k pot into w1
- temp_set = temp_set / 8 ; makes a value from 0 - 127 cool trick this
- sertxd ("+" , #temperature , " degrees DS18B20 ") ; to terminal
- sertxd (#temp_set, " 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 temperature >= temp_set then goto 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 temperature <= temp_set then relay_on1
- LOW RELAY1
- gosub wait_here
- goto main
- relay_on1: ; function
- HIGH RELAY1
- gosub wait_here
- goto main
- wait_here: ; function
- for loop_counter = 1 to MINUTES_PAUSE ; 10-second loops
- pause 10000 ; wait 10 seconds
- next loop_counter
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement