import time enabled = True while True: if enabled: pin_led.on() time.sleep else: pin_led.off() enabled = not enabled time.sleep(1)