Feb-17-2020, 07:15 PM
Hi Team
My requirement is read data from arduino through serial port
and put it to the Entry widget
Every this is successful but only issue is The Entry Widget does not open but I can oen it with combine plot widget
Please advice to open Entry widget without plot widget
My requirement is read data from arduino through serial port
and put it to the Entry widget
Every this is successful but only issue is The Entry Widget does not open but I can oen it with combine plot widget
Please advice to open Entry widget without plot widget
import serial from tkinter import * import matplotlib.pyplot as plt from drawnow import * values = [] root = Tk() plt.ion() cnt=0 #serialArduino = serial.Serial('/dev/ttyACM0', 19200) serialArduino = serial.Serial('COM3',baudrate = 9600, timeout = 1) root.title("D Cube Serial Read") e = Entry(root,width = 35, borderwidth = 5) e.grid(row = 0, column = 0, columnspan = 3,padx = 10,pady = 10) def plotValues(): plt.title('Serial value from Arduino') plt.grid(True) plt.ylabel('Values') plt.plot(values, 'rx-', label='values') plt.legend(loc='upper right') #pre-load dummy data for i in range(0,26): values.append(0) while True: while (serialArduino.inWaiting()==0): pass valueRead = serialArduino.readline() print(valueRead) #check if valid value can be casted try: valueInInt = int(valueRead) print(valueInInt) if valueInInt <= 1024: if valueInInt >= 0: e.delete(0,END) e.insert(1,valueInInt) values.append(valueInInt) values.pop(0) drawnow(plotValues) else: print ("Invalid! negative number") else: print ("Invalid! too large") except ValueError: print ("Invalid! cannot cast")Thanks in advanced