Guest User

Untitled

a guest
Aug 25th, 2022
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. from time import sleep
  2. from machine import Pin, PWM
  3. from machine import Pin
  4.  
  5. led = Pin(25, Pin.OUT)
  6.  
  7. pwm = PWM(Pin(0))
  8. pwm.freq(50)
  9.  
  10. off = 3000
  11. fourtyfive = 5000
  12. seventy = 8000
  13. one_hour = 3600 # 3600 in prod 5 is test
  14. rotation_time = 3
  15. rotations_per_loop = 5
  16.  
  17. # power reset unit at 20:00 to get extra hot water
  18.  
  19. print("70")
  20. pwm.duty_u16(seventy)
  21. sleep(rotation_time)
  22. pwm.duty_u16(0)
  23. sleep(2*one_hour)
  24. print("off")
  25. pwm.duty_u16(off)
  26. sleep(rotation_time)
  27. pwm.duty_u16(0)
  28.  
  29. # time was 22:00
  30. sleep(2*one_hour)
  31.  
  32. while True:
  33. print("time is 00:00")
  34. sleep(2.5*one_hour)
  35. # time is 2:30
  36. pwm.duty_u16(fourtyfive)
  37. sleep(rotation_time) #1
  38. pwm.duty_u16(0)
  39.  
  40. sleep(1*one_hour)
  41. # time is 3:30
  42. pwm.duty_u16(seventy)
  43. sleep(rotation_time) #2
  44. pwm.duty_u16(0)
  45.  
  46. sleep(2*one_hour)
  47. # time is 05:30
  48. pwm.duty_u16(off)
  49. sleep(rotation_time) #3
  50. pwm.duty_u16(0)
  51.  
  52. sleep(8*one_hour)
  53. # time is 13:30
  54. led.toggle()
  55. pwm.duty_u16(fourtyfive)
  56. sleep(rotation_time) #4
  57. pwm.duty_u16(0)
  58.  
  59. sleep(1*one_hour)
  60. # time is 14:30
  61. led.toggle()
  62. pwm.duty_u16(off)
  63. sleep(rotation_time) #5
  64. pwm.duty_u16(0)
  65.  
  66. sleep(9.5*one_hour - rotations_per_loop*rotation_time)
  67. # time is 00:00
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment