from machine import Pin, PWM
import utime
ch = PWM(Pin(0)) # PWM at GP0
ch.freq(1000) # Frequency = 1000Hz
i = 0
while True: # Do forever
ch.duty_u16(i) # Change duty cycle
utime.sleep_ms(300) # Delay 300ms
i = i + 5000 # Increment i
if i > 65535:
i = 0