#!/usr/bin/env python

# servo_key.py
# 2015-04-10
# Public Domain

import time
from Tkinter import *
import pigpio 
import os
SERVO = 18
pi = pigpio.pi()
os.system('sudo pigpiod')
class App:
    def __init__(self,master):
        frame=Frame(master)
        frame.pack()
        scale=Scale(frame,from_=0,to=2000,orient=HORIZONTAL,command=self.update)
        scale.grid(row=0)

    def update(self,angle):
        duty=float(angle)+500
        pi.set_servo_pulsewidth(SERVO, duty)


root=Tk()
root.wm_title('Servo COntrol')
app=App(root)
root.geometry("200x50+0+0")
root.mainloop()
pi.stop()
os.system('sudo killall pigpiod')


   
