I would propose to add some print statements which help to understand what is going on:Start the code with the small green icon in thonny:You should see this in 'Shell' view of thonny:
Code:
import machineimport timeprint("your program is running now")switch = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_DOWN)LED = machine.Pin("LED", machine.Pin.OUT)while True: if switch.value(): print("button 1") LED.value(True) else: print("button 0") LED.value(False) time.sleep(0.1) # makes loop a bit slower, but thonny can't handle too fast printoutStatistics: Posted by ghp — Tue Feb 24, 2026 9:40 pm