from machine import Pin, ADC
from time import sleep_us
potentiometer=ADC(Pin(28))
pot = ADC(Pin(26))
servo=Pin(0,Pin.OUT)
while True:
servo.on() #start a PWM pulse
#calculate a pulse width between 1000-2000 microseconds
# pulseWidth=int(1000+1000*potentiometer.read_u16()/65536)
pulseWidth=int(1000+1000*pot.read_u16()/65536)
print(pulseWidth)
sleep_us(pulseWidth)
servo.off() #end a PWM pulse
sleep_us(20000-pulseWidth) #wait for a while before next pulse