from machine import Pin # Import Pin class to control GPIO pins
from time import sleep # Import sleep function for time delays
led = Pin(2,Pin.OUT) # Create Pin object for GPIO2, set as output
while True: # This is the main loop (endless)
# Toggle the led.
# Read the current state of the LED, invert it, and write it back.
led.value( not led.value() )
# Print the current state of the LED to the serial console.
print( f"LED: {led.value()}" )
# Wait for 1 second before toggling again.
Sleep(1.0)