Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import serial
- import Tkinter as tk
- from Tkinter import *
- try:
- arduino = serial.Serial( '/dev/ttyACM0', 9600 )
- except:
- print "Cannot conect to the port"
- def LED1():
- arduino.write('U')
- print "Se encendio el led 1"
- def LED2():
- arduino.write('D')
- print "Se encendio el led 2"
- def LED3():
- arduino.write('T')
- print "Se encendio el led 3"
- def LED4():
- arduino.write('C')
- print "Se encendio el led 4"
- def motor():
- arduino.write('M')
- print "Se encendio el motor"
- root = Tk()
- button1 = Button(root, text="LED 1", command=LED1)
- button1.grid(row=1, column=1)
- button2 = Button(root, text="LED 2", command=LED2)
- button2.grid(row=1, column=2)
- button3 = Button(root, text="LED 3", command=LED3)
- button3.grid(row=1, column=3)
- button4 = Button(root, text="LED 4", command=LED4)
- button4.grid(row=1, column=4)
- button5 = Button(root, text="Motor", command=motor)
- button5.grid(row=1, column=5)
- root.title('GUI de Leds')
- root.geometry("320x70")
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement