Skip to content

Instantly share code, notes, and snippets.

@hnaohiro
Created November 15, 2013 07:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnaohiro/7480566 to your computer and use it in GitHub Desktop.
Save hnaohiro/7480566 to your computer and use it in GitHub Desktop.
BeagleBone Black | Adafruit | Python | Servo Motor
import Adafruit_BBIO.PWM as PWM
servo_pin = "P8_13"
duty_min = 3
duty_max = 14.5
duty_span = duty_max - duty_min
PWM.start(servo_pin, duty_min, 60.0)
while True:
v = raw_input("Angle (0 to 1.0 x to exit):")
if v == 'x':
PWM.stop(servo_pin)
PWM.cleanup()
break
v = float(v)
if v < 0:
v = 0
elif v > 1:
v = 1
duty = float(v) * duty_span + duty_min
PWM.set_duty_cycle(servo_pin, duty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment