Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(14, GPIO.OUT)
- GPIO.output(14, GPIO.LOW)
- q = GPIO.PWM(14,50)
- num = 5
- window =tkinter.Tk()
- def fan_on():
- q.start(5)
- def fan_off():
- q.ChangeDutyCycle(0)
- def speed_up():
- global num
- num += 10
- q.ChangeDutyCycle(num)
- def speed_down():
- global num
- num -= 10
- q.ChangeDutyCycle(num)
- def quit():
- GPIO.cleanup()
- exit()
- btn1 = tkinter.Button(window, text="Fan 0n" ,command=fan_on)
- btn2 = tkinter.Button(window, text="Fan Off" ,command=fan_off)
- btn3 = tkinter.Button(window, text="SPEED UP ⬆" ,command=speed_up)
- btn4 = tkinter.Button(window, text="SPEED DOWN ⬇" ,command=speed_down)
- #lbl = tkinter.Label(window, text="temp.°C")
- btn5 = tkinter.Button(window, text="Quit" ,command=quit)
- btn1.place(x=0 , y=20)
- btn2.place(x=328, y=20)
- btn3.pack()
- btn4.pack()
- btn5.place(y=300)
- #lbl.place(x=180, y=180)
- window.geometry("400x400")
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement