Skip to content

Instantly share code, notes, and snippets.

@pfcoperez
Created July 8, 2025 18:17
Show Gist options
  • Save pfcoperez/864d1b382a8362fa9080e7f1d687dae0 to your computer and use it in GitHub Desktop.
Save pfcoperez/864d1b382a8362fa9080e7f1d687dae0 to your computer and use it in GitHub Desktop.
Micropythong example to control g9 microservos
import time
from machine import Pin, PWM
pwm = PWM(Pin(4))
pwm.freq(50)
def demo():
st = False
for x in range(1,10):
if st:
pwm.duty_u16(int(65536*0.5/20))
else:
pwm.duty_u16(int(65536*2/20))
st = not st
time.sleep(2)
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment