from machine import Pin , PWM, ADC
from time import sleep
vr = ADC(Pin(34)) #define pin as ADC
vr.width(ADC.WIDTH_10BIT) #2^10 = 1024 , range 0-1023 to match duty cycle
vr.atten(ADC.ATTN_11DB) #11dB , gives a maximum input voltage = 3.6V
led=PWM(Pin(13),5000)
while True:
led.duty(vr.read()) #duty cycle, range 0-1023
sleep(0.5)