from machine import Pin,PWM,ADC
import time

led = PWM(Pin(17,Pin.OUT),20000)

adc = ADC(Pin(27))
adc.atten(ADC.ATTN_11DB)

while True:
    led.duty_u16(adc.read_u16())
    time.sleep(0.5)
    print(f'{adc.read_u16()}')