from machine import ADC,Pin,PWM
from time import sleep

pot=ADC(Pin(27))
pwm=PWM(Pin(9))
pwm.freq(1000)

while True:
    value=pot.read_u16()
    print(value)
    pwm.duty_u16(value)
    sleep(0.5)