Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from serial import *
- from tkinter import *
- serialPort = "/dev/ttyUSB0"
- baudRate = 9600
- ser = Serial(serialPort, baudRate, timeout=0, writeTimeout=0)
- def mW():
- ser.write(b'1\r\n')
- return
- def mA():
- ser.write(b'2\r\n')
- return
- def mZ():
- ser.write(b'3\r\n')
- return
- def mX():
- ser.write(b'4\r\n')
- return
- def mD():
- ser.write(b'5\r\n')
- return
- def mS():
- ser.write(b'6\r\n')
- return
- def mT():
- ser.write(b'7\r\n')
- return
- def mR():
- ser.write(b'8\r\n')
- return
- root=Tk()
- Forward=Button(text="Forward", bg="blue", fg="white",command=mW)
- Left=Button(text="Left", bg="blue", fg="white",command=mA)
- Center=Button(text="Center", bg="blue", fg="white",command=mZ)
- Stop=Button(text="Stop", bg="red", fg="white",command=mX)
- Right=Button(text="Right", bg="blue", fg="white",command=mD)
- Reverse=Button(text="Reverse", bg="blue", fg="white",command=mS)
- Faster=Button(text="Faster", bg="blue", fg="white",command=mT)
- Slower=Button(text="Slower", bg="blue", fg="white",command=mR)
- Forward.config(height=10,width=10)
- Left.config(height=10,width=10)
- Center.config(height=10,width=10)
- Stop.config(height=10,width=10)
- Right.config(height=10,width=10)
- Reverse.config(height=10,width=10)
- Faster.config(height=5,width=10)
- Slower.config(height=5,width=10)
- Forward.grid(row=0,column=1,padx=20,pady=20)
- Left.grid(row=1,column=0,padx=20,pady=20)
- Center.grid(row=1,column=1,padx=20,pady=20)
- Stop.grid(row=0,column=2,padx=20,pady=20)
- Right.grid(row=1,column=2,padx=20,pady=20)
- Reverse.grid(row=2,column=1,padx=20,pady=20)
- Faster.grid(row=0,column=0,padx=20,pady=20)
- Slower.grid(row=2,column=0,padx=20,pady=20)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement