Skip to content

Instantly share code, notes, and snippets.

@kism3t1
Created March 12, 2012 21:07
Show Gist options
  • Select an option

  • Save kism3t1/2024685 to your computer and use it in GitHub Desktop.

Select an option

Save kism3t1/2024685 to your computer and use it in GitHub Desktop.
GUI for controlling Arduino LED & lCD
import tkinter
import time
import serial
ser = serial.Serial ('/dev/ttyUSB0',9600) #Used for Pro Mini
class gui(tkinter.Tk):
def __init__(self,parent):
tkinter.Tk.__init__(self,parent)
self.parent = parent
#ser = serial.Serial ('/dev/ttyACM0',9600)
self.initialize()
def initialize(self):
self.grid()
#self.entry = Tkinter.Entry(self)
#self.entry.grid(column=0, row=0, sticky='EW')
Label = tkinter.Label(self, text='. .')
Label.grid(column=1, row=0)
button = tkinter.Button(self, text="Turn LED on!",
command=self.OnButtonClick)
button.grid(column=0, row=1)
button = tkinter.Button(self, text="Turn LED off!",
command=self.OffButtonClick)
button.grid(column=2, row=1)
button = tkinter.Button(self, text="Send booted message",
command=self.BootedButton)
button.grid(column=3, row=1)
def OnButtonClick(self):
print("You clicked the ON button!")
ser.write("Y")
Label = tkinter.Label(self, text='LED ON')
Label.grid(column=1, row=0)
def OffButtonClick(self):
print("You clicked the OFF button!")
ser.write("N")
Label = tkinter.Label(self, text='LED OFF')
Label.grid(column=1, row=0)
def BootedButton(self):
print("You clicked the booted button")
ser.write("B")
Label = tkinter.Label(self, text='Sent Booted msg')
Label.grid(column=1, row=0)
if __name__ == "__main__":
app = gui(None)
app.title('Turn LED On & Off')
app.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment