Advertisement
ossipee

fan code

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