I have searched high and low. What is the smallest amount of code to show text of a temprature reading from an arduino in a window that updates every second?
Asked
Active
Viewed 649 times
-2
-
Are you asking us to do all the work for you? Stackoverflow isn’t a free code-writing service. There are many arduino+tkinter questions on this site. Have you done any research? – Bryan Oakley Nov 24 '17 at 21:27
-
if you put all code in module then program may need only one line `import module`;) – furas Nov 25 '17 at 08:58
-
Oh yes the work has been done and the research followed for 3 weeks now. The issue I keep comeng up against is the half knowledge I have with Python. Below is where I am at. I would put the 12 different attempsts I have made but it migh be a TLDR situation. – Matthew Ian Clarke Nov 25 '17 at 16:28
-
What i am trying todo is add a temp reading in the centre but am not winning. – Matthew Ian Clarke Nov 25 '17 at 16:32
1 Answers
0
import tkinter
import time
import serial
ser = serial.Serial ('com24',9600)
class gui(tkinter.Tk):
def __init__(self,master):
tkinter.Tk.__init__(self,master)
self.master = master
self.initialize()
def initialize(self):
self.lounge = tkinter.Button(self, text="Lounge Lights",width=15,height=6,command=self.Lounge,font = "Times",bg="#42d7f4")
self.lounge.grid(row=0, column=0, pady=5, padx=5)
self.kitchen = tkinter.Button(self, text="Kitchen Lights",width=15,height=6,command=self.Kitchen,font = "Times",bg="#42d7f4")
self.kitchen.grid(row=0, column=1, pady=5, padx=5)
self.bedroom = tkinter.Button(self, text="Bedroom Lights",width=15,height=6,command=self.Bedroom,font = "Times",bg="#42d7f4")
self.bedroom.grid(row=0, column=2, pady=5, padx=5)
self.ph1 = tkinter.Label(self, text="TIME",width=15,height=6,font = "Times",bg="#42d7f4")
self.ph1.grid(row=1, column=0, pady=5, padx=5,sticky=tkinter.E)
self.ph2 = tkinter.Label(self, text="Img",width=15,height=6,font = "Times",bg="#42d7f4")
self.ph2.grid(row=1, column=2, pady=5, padx=5,sticky=tkinter.W)
def Lounge(self,ll=[0]):
ll[0] = not ll[0]
if ll[0]:
self.lounge.configure(text = 'Lounge Lights OFF')
ser.write('a')
else:
self.lounge.configure(text = 'Lounge Lights ON')
ser.write('d')
def Kitchen(self,kl=[0]):
kl[0] = not kl[0]
if kl[0]:
self.kitchen.configure(text = 'Kitchen Lights OFF')
ser.write('b')
else:
self.kitchen.configure(text = 'Kitchen Lights ON')
ser.write('e')
def Bedroom(self,br=[0]):
br[0] = not br[0]
if br[0]:
self.bedroom.configure(text = 'Bedroom Lights OFF')
ser.write('c')
else:
self.bedroom.configure(text = 'Bedroom Lights ON')
ser.write('f')
if __name__ == "__main__":
app = gui(None)
app.title("PyWiFiLiGhTs")
app.mainloop()

Matthew Ian Clarke
- 37
- 10