Skip to content

Instantly share code, notes, and snippets.

@lean8086
Last active June 12, 2022 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lean8086/7319725de80bcc135af5a1c883dda6d0 to your computer and use it in GitHub Desktop.
Save lean8086/7319725de80bcc135af5a1c883dda6d0 to your computer and use it in GitHub Desktop.
Hello world for servo motors on a Pico with MicroPython
from machine import Pin,PWM
import utime
MID = 1500000
MIN = 1000000
MAX = 2000000
led = Pin(25,Pin.OUT)
pwm = PWM(Pin(15))
pwm.freq(50)
pwm.duty_ns(MID)
while True:
pwm.duty_ns(MIN)
utime.sleep(1)
pwm.duty_ns(MID)
utime.sleep(1)
pwm.duty_ns(MAX)
utime.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment