Created
November 3, 2019 16:02
-
-
Save rmrf-run/70da874415eea91127c186758705ac0d to your computer and use it in GitHub Desktop.
servo control with circuit python and trinket m0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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