A collection of examples for using the gpiozero library for reading sensors and activating actuators
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
618 B

from gpiozero import Servo
from time import sleep
# https://gpiozero.readthedocs.io/en/stable/recipes.html#servo
#these pulse-width values come from the elektrobit product description
maxPW=2.1/1000
minPW=0.9/1000
# these values are empirically determined and represent maxima
# 0.3 will turn slow in one direction, -0.5 slow in the other
left = 1
right = -1
stop = -0.2
servo = Servo(
17,
initial_value=None,
min_pulse_width=minPW,
max_pulse_width=maxPW)
while True:
servo.value = left
sleep(1)
servo.value = right
sleep(1)
servo.value = stop
sleep(2)