Trying to get my GUI to communicate with PyMata
to turn an LED off and on based on the check button.
The wiring and PyMata
code is fine since I can get the LED to blink off and on again but I cant get the LED to turn off or on based on the checkbox
My checkbox has this as the code right now.
light_state = BooleanVar()
light = Checkbutton(window, text='LED Light', font = ("Times New Roman",10), var = light_state, onvalue=True, offvalue=False)
and my pymata loop is
while True:
window.update()
if light_state==True:
board.digital[pinLED].write(1)
elif light_state==False:
board.digital[pinLED].write(0)
Any help is appreciated
After setting print statements to see what was happening to the variable it kept printing PY_VAR0 which I found was cause the variable wouldn't update its self you had to get it using the .get command. My code turned into
and all works well now, hopefully this helps someone else sometime