Python Forum

Full Version: Tkinter/Label/Arduino/ if Else condition
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
from Tkinter import *
root = Tk()
def connectToArduino():

    arduino = serial.Serial(arduinoPort,   serialTransferRate)
    arduino.timeout = None
    time.sleep(2)
    arduino.write("S\n")

    lab=Label(root, text="Connected")
    lab.grid()
    return arduino, lab
    lab.config(text="Disconnected")
arduino = connectToArduino()
arduino.pack()
root.mainloop()
When Arduino Connected serial to PC,Label has Connected MSG.When discomnected,MSG is disconnected.
How could i make if Else condition about Connected or Disconnected messages in Label?
Send a request (ping) to the arduino to which it will respond if connected
If you get a response, just make sure it's not a timeout, and you have your
trigger for messages.

You can get some other idea's here: http://www.instructables.com/id/Interfac...-pySerial/