Advertisement
safwan092

Untitled

May 14th, 2023
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import tkinter as tk
  3. from tkinter import *
  4. import serial
  5. import time
  6. from tkinter import filedialog
  7. import threading
  8. import continuous_threading
  9.  
  10. ser = serial.Serial('/dev/ttyACM0',9600,timeout=1)
  11.  
  12. input_str = ser.readline()
  13. print("Read input"+ input_str.decode("utf-8").strip() + " from Arduino")
  14.  
  15. root = tk.Tk()
  16. root.geometry("500x500")
  17.  
  18. #while 1:
  19. def readserial():
  20. input_str = ser.readline().decode("utf-8").strip()
  21. print("Received Text : "+ input_str)
  22. frame=Frame(root, width=500, height=500)
  23. frame.grid(row=0, column=0, sticky="NW")
  24. label=Label(root, text="Received Text : "+ input_str, font='Arial 50 bold')
  25. label.place(relx=0.5, rely=0.5, anchor=CENTER)
  26.  
  27. t1 = continuous_threading.PeriodicThread(0.5, readserial)
  28. t1.start()
  29. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement