Created
          November 15, 2013 07:35 
        
      - 
      
 - 
        
Save hnaohiro/7480566 to your computer and use it in GitHub Desktop.  
    BeagleBone Black | Adafruit | Python | Servo Motor
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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