from machine import Pin,PWM
import time
MG966R = PWM(Pin(2, mode=Pin.OUT))
MG966R.freq(50)
#0.5ms/20ms = 0.025 = 2.5% duty cycle
#2.4ms/20ms = 0.12 = 12% duty cycle
#0.025*1024=25.6
#0.12*1024=122.88
while True:
MG966R.duty(26)
time.sleep(1)
MG966R.duty(123)
time.sleep(1)