Skip to content

Instantly share code, notes, and snippets.

@mollyporph
Created August 31, 2015 14:58
Show Gist options
  • Save mollyporph/af1c5c06106283efdfb7 to your computer and use it in GitHub Desktop.
Save mollyporph/af1c5c06106283efdfb7 to your computer and use it in GitHub Desktop.
#import PWM
#pwm = PWM(0x40)
#pwm.setPWMFreq(60) #60hz
servoMin = 1
servoMax = 800
def setPWMDegrees(channel,degrees):
clampedValue = max(1,min(degrees,360))
fraction = clampedValue / 360
pwmValue = round(fraction * servoMax)
print(pwmValue)
#pwm.setPWM(channel,pwmValue)
setPWMDegrees(1,360)
setPWMDegrees(1,800)
setPWMDegrees(1,90)
setPWMDegrees(1,180)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment