Skip to content

Instantly share code, notes, and snippets.

@gigafide
Last active January 30, 2023 21:01
Show Gist options
  • Save gigafide/9d50d70013badcccb651b7fed95c4538 to your computer and use it in GitHub Desktop.
Save gigafide/9d50d70013badcccb651b7fed95c4538 to your computer and use it in GitHub Desktop.
Simple Raspberry Pi Pico Servo Sweep
from machine import Pin, PWM
import time
servo = PWM(Pin(0))
servo.freq(50)
while True:
for position in range(1000, 9000, 50):
servo.duty_u16(position)
time.sleep(0.1)
for position in range(9000, 1000, -50):
servo.duty_u16(position)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment