from machine import Pin,PWM
from time import sleep

led = PWM(Pin(5,Pin.OUT),freq = 5000)

while True:
    for dutyCycle in range(0,1024):
        led.duty(dutyCycle)
        sleep(0.005)
    for dutyCycle in range(1023,0,-1):
        led.duty(dutyCycle)
        sleep(0.005)