Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import tkinter
  2. import RPi.GPIO as GPIO
  3. import time
  4.  
  5. GPIO.setmode(GPIO.BCM)
  6. GPIO.setup(14, GPIO.OUT)
  7. GPIO.output(14, GPIO.LOW)
  8.  
  9. q = GPIO.PWM(14,50)
  10.  
  11.  
  12. num = 5
  13.  
  14.  
  15.  
  16.  
  17.  
  18. window =tkinter.Tk()
  19.  
  20. def fan_on():
  21. q.start(5)
  22.  
  23.  
  24. def fan_off():
  25. q.ChangeDutyCycle(0)
  26.  
  27.  
  28.  
  29. def speed_up():
  30. global num
  31. num += 10
  32. q.ChangeDutyCycle(num)
  33.  
  34.  
  35.  
  36.  
  37. def speed_down():
  38. global num
  39. num -= 10
  40. q.ChangeDutyCycle(num)
  41.  
  42.  
  43. def quit():
  44. GPIO.cleanup()
  45. exit()
  46.  
  47. btn1 = tkinter.Button(window, text="Fan 0n" ,command=fan_on)
  48. btn2 = tkinter.Button(window, text="Fan Off" ,command=fan_off)
  49. btn3 = tkinter.Button(window, text="SPEED UP ⬆" ,command=speed_up)
  50. btn4 = tkinter.Button(window, text="SPEED DOWN ⬇" ,command=speed_down)
  51. #lbl = tkinter.Label(window, text="temp.°C")
  52.  
  53. btn5 = tkinter.Button(window, text="Quit" ,command=quit)
  54.  
  55. btn1.place(x=0 , y=20)
  56. btn2.place(x=328, y=20)
  57. btn3.pack()
  58. btn4.pack()
  59. btn5.place(y=300)
  60. #lbl.place(x=180, y=180)
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. window.geometry("400x400")
  68.  
  69. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement