# PWM control of a servo motor without any external libraries
from machine import Pin
from time import sleep_us
servo=Pin(0,Pin.OUT)
pulseWidth=1000
while True:
#create a small high pulse followed by a longer low signal with a total period of 20ms
servo.on()
sleep_us(pulseWidth)
servo.off()
sleep_us(20000-pulseWidth)
print(pulseWidth)
pulseWidth=pulseWidth+1; #change the increment to change the speed of the servo
if pulseWidth>2000:
pulseWidth=1000