Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import tkinter as tk
- from tkinter import *
- import serial
- import time
- from tkinter import filedialog
- import threading
- import continuous_threading
- ser = serial.Serial('/dev/ttyACM0',9600,timeout=1)
- input_str = ser.readline()
- print("Read input"+ input_str.decode("utf-8").strip() + " from Arduino")
- root = tk.Tk()
- root.geometry("300x250")
- #while 1:
- def readserial():
- input_str = ser.readline().decode("utf-8").strip()
- print("Received Text : "+ input_str)
- frame=Frame(root, width=300, height=250)
- frame.grid(row=0, column=0, sticky="NW")
- label=Label(root, text="Received Text : "+ input_str, font='Arial 50 bold')
- label.place(relx=0.5, rely=0.5, anchor=CENTER)
- t1 = continuous_threading.PeriodicThread(0.5, readserial)
- t1.start()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement