Created
March 6, 2013 22:00
-
-
Save akbsteam/5103492 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
from Adafruit_PWM_Servo_Driver import PWM | |
import time | |
pwm = PWM(0x40) | |
pwm.setPWMFreq(50) | |
twist = 200 | |
tDir = 1 | |
tMax = 300 | |
tMin = 200 | |
nod = 200 | |
nDir = 1 | |
nMax = 500 | |
nMin = 120 | |
def twistServo(): | |
global twist | |
global tDir | |
global tMax | |
global tMin | |
twist += tDir | |
if (twist > tMax): | |
tDir = -1 | |
elif (twist < tMin): | |
tDir = 1 | |
pwm.setPWM(0, 0, twist) | |
def nodServo(): | |
global nod | |
global nDir | |
global nMax | |
global nMin | |
nod += nDir | |
if (nod > nMax): | |
nDir = -1 | |
elif (nod < nMin): | |
nDir = 1 | |
pwm.setPWM(15, 0, nod) | |
while (True): | |
twistServo() | |
nodServo() | |
time.sleep(0.005) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment