Last active
October 3, 2016 18:22
-
-
Save Workshopshed/7f15298907957ab89ab74de4c2058d89 to your computer and use it in GitHub Desktop.
Controlling a Raspberry Pi Servo with RPIO
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
from RPIO import PWM | |
from time import sleep | |
servo = PWM.Servo() | |
# https://pythonhosted.org/RPIO/pwm_py.html | |
# BCM GPIO numbering | |
# From Arduino Servo library, standards are: | |
# min is 544, max is 2400 | |
# But for RPIO need to be in multiples of 10us | |
# Fully left | |
servo.set_servo(18, 540) | |
sleep(5) | |
#Middle | |
servo.set_servo(18, 1470) | |
sleep(5) | |
#Full right | |
servo.set_servo(18, 2400) | |
#Give it time to move to last position before turning off | |
sleep(1) | |
# Clear servo | |
servo.stop_servo(18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment