Thursday, July 18, 2013

Python GUI

Made a GUI with python to control the on-board LED a few days ago. Seems to be really responsive. Also made the program in Visual C++ on Windows.
#!/usr/bin/python
from Tkinter import *
import serial

arduino = serial.Serial('/dev/ttyACM0', 9600)

def ledOn():
 arduino.write('a')
 return 

def ledOff():
 arduino.write('b')
 return 

app = Tk()
app.title("Blink")
app.geometry('125x75+200+200')

buttonON = Button(app, text = 'LED ON', command = ledOn)
buttonON.pack(padx = 10, pady = 5)

buttonOFF = Button(app, text = 'LED OFF', command = ledOff)
buttonOFF.pack(padx = 10, pady = 5)

app.mainloop()

No comments:

Post a Comment