from machine import Pin,PWM,ADC
adc=ADC(Pin(32))
adc.width(ADC.WIDTH_9BIT)
adc.atten(ADC.ATTN_11DB)
pwm=PWM(Pin(5),freq=50)
while(1):
v=adc.read()
if(v<=127):
pwm.duty(25)
elif(v<=254):
pwm.duty(50)
elif(v<=381):
pwm.duty(90)
else:
pwm.duty(125)