Last active
August 29, 2015 14:23
-
-
Save staroselskii/06f24e9b085782ccf1cd to your computer and use it in GitHub Desktop.
HS-85BB++ Servo Navio Control
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
frequency = 50 | |
NAVIO_RCOUTPUT_1 = 3 | |
SERVO_MID_ms = 1.500 | |
SERVO_MIN_ms = 1.050 # mS | |
SERVO_MAX_ms = 1.950 # mS | |
#convert mS to 0-4096 scale: | |
SERVO_MID = math.trunc((SERVO_MID_ms * 4096.0) / (1000.0 / frequency) - 1) | |
SERVO_MIN = math.trunc((SERVO_MIN_ms * 4096.0) / (1000.0 / frequency) - 1) | |
SERVO_MAX = math.trunc((SERVO_MAX_ms * 4096.0) / (1000.0 / frequency) - 1) | |
pwm = PWM(0x40, debug=True) | |
pwm.setPWMFreq(frequency) | |
while(True): | |
pwm.setPWM(NAVIO_RCOUTPUT_1, 0, SERVO_MID) | |
time.sleep(3) | |
pwm.setPWM(NAVIO_RCOUTPUT_1, 0, SERVO_MIN) | |
time.sleep(3) | |
pwm.setPWM(NAVIO_RCOUTPUT_1, 0, SERVO_MAX) | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment