Advertisement
ossipee

birdmun rules

Feb 5th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2.  
  3. ; brain
  4. ; picaxe 08m2
  5. setfreq m4 ; 4mhz clock
  6.  
  7. symbol DS18B20_PIN = C.4 ; dallas pin
  8. symbol CONTROL_PIN = C.2 ; pot pin
  9. symbol RELAY1 = C.1 ; fan relay pin 120v
  10. symbol MINUTES_PAUSE = 1 ; delay 1 minute for subroutine
  11.  
  12. LOW RELAY1
  13.  
  14. symbol SW1 = pinC.3 ; switching pin
  15. pullup %00001000 ; internal pullup pinC.1 for switch
  16. symbol temperature = w1
  17. symbol temp_set = w2
  18. symbol loop_counter = b5
  19.  
  20. main:
  21. readtemp DS18B20_PIN, temperature ; read sensor value into w1
  22. temperature = temperature * 9 / 5 + 32 ; convert to farenhieght
  23.  
  24. readadc10 CONTROL_PIN, temp_set ; use adc to read 10k pot into w1
  25. temp_set = temp_set / 8 ; makes a value from 0 - 127 cool trick this
  26.  
  27. sertxd ("+" , #temperature , " degrees DS18B20 ") ; to terminal
  28. sertxd (#temp_set, " pot setting " ,13, 10) ; to terminal
  29.  
  30. if SW1 = 0 then goto heater_on
  31.  
  32. ; air conditioner on
  33. ; power on if DS18B20 (w1) >= pot (w2)
  34. ; this assumes the AC is on
  35.  
  36. if temperature >= temp_set then goto relay_on1
  37. LOW RELAY1
  38. gosub wait_here
  39. goto main
  40.  
  41. heater_on: ; function
  42.  
  43. ; power on if DS18B20 (w1) <= pot (w2)
  44. ; this assumes pellet stove is running and we can use it to warm pipes
  45.  
  46. if temperature <= temp_set then relay_on1
  47. LOW RELAY1
  48. gosub wait_here
  49. goto main
  50.  
  51. relay_on1: ; function
  52. HIGH RELAY1
  53. gosub wait_here
  54. goto main
  55.  
  56. wait_here: ; function
  57. for loop_counter = 1 to MINUTES_PAUSE ; 10-second loops
  58. pause 10000 ; wait 10 seconds
  59. next loop_counter
  60. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement