import time
from machine import Pin, PWM
led = PWM(Pin(0))
led.freq(1000) #1000 cycles per second
x = 0 #duty cycle
#duty cycle has to be between 0 to 65535 that is 16 bit unsigned integer
while True:
led.duty_u16(x)
time.sleep(0.6)
x += 20000
if x > 65535:
x = 0