Skip to content

Instantly share code, notes, and snippets.

@rmrf-run
Created November 3, 2019 16:02
Show Gist options
  • Save rmrf-run/70da874415eea91127c186758705ac0d to your computer and use it in GitHub Desktop.
Save rmrf-run/70da874415eea91127c186758705ac0d to your computer and use it in GitHub Desktop.
servo control with circuit python and trinket m0
import board
import digitalio
import time
import pulseio
import adafruit_motor.servo
import random
pwm = pulseio.PWMOut(board.A2, frequency=50)
servo = adafruit_motor.servo.Servo(pwm, min_pulse=900, max_pulse=2400)
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT
while True:
for i in range(0,180):
led.value = True
servo.angle = i
led.value = False
time.sleep(.1)
for i in range(180,0,-1):
led.value = True
servo.angle = i
led.value = False
time.sleep(.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment