Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. from tkinter import *
  2. import RPi.GPIO as GPIO
  3. import time
  4.  
  5. GPIO.setmode(GPIO.BCM)
  6. GPIO.setup(18, GPIO.OUT)
  7. pwm = GPIO.PWM(18, 100)
  8. pwm.start(5)
  9.  
  10. class App:
  11.  
  12. def __init__(self, master):
  13. frame = Frame(master)
  14. frame.pack()
  15. scale = Scale(frame, from_=0, to=180,
  16. orient=HORIZONTAL, command=self.update)
  17. scale.grid(row=0)
  18.  
  19.  
  20. def update(self, angle):
  21. duty = float(angle) / 10.0 + 2.5
  22. pwm.ChangeDutyCycle(duty)
  23.  
  24. root = Tk()
  25. root.wm_title('Servo Control')
  26. app = App(root)
  27. root.geometry("200x50+0+0")
  28. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement