import board
import time
import pwmio

# Create a PWMOut object on an LED pin
led = pwmio.PWMOut(board.GP26, duty_cycle=0, frequency=5000)

# Change Duty Cycle Value to max 16 bit
led.duty_cycle = 32768

while True: # Loop for the board to execute the function and continue 
to do 
    for i in range(100):
        # PWM LED up and down
        if i < 50:
            #Turn on from less to more (Up)
            led.duty_cycle = int(i * 2 * 65535 / 100) 
            
        else:
            #Inverted: Turn on from more to less (Down)
            led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) 
            
        time.sleep(0.3)

C I R C U I T P Y T H O N