-
Notifications
You must be signed in to change notification settings - Fork 87
Servo
Servo is a library for controlling servo motors using the BeagleBone's PWM pins. There can be up to four servos connected, as PyBBIO currently only supports four PWM outputs. Note that servos require a PWM signal at 50Hz, and the four PWM outputs are controlled by two PWM modules, each of which generates a single frequency. This means that if a servo is attached to PWM1A, then PWM1B will be running at 50Hz. See the PWM docs for more info.
There is an example program at PyBBIO/examples/Servo_sweep.py.
This creates an instance of the Servo class. pwm_pin can be one of PWM1A, PWM1B, PWM2A or PWM2B, and if given Servo.attach(pwm_pin) will be called. The optional argument pwm_freq is the PWM frequency in Hertz, which is 50Hz for most servos. The optional min_ms and max_ms are the duration of the high pulse to indicate 0 and 180 degrees respectively. These values may need some tweaking to get the full range depending on the servo.
Attaches the servo object to the given pin. This must be called if no pin was passed in when the Servo class was initialized, and can also be used to change pins.
Sets the shaft of the servo motor to the given angle in degrees.
returns the last value passed to write().
Disables PWM output on the attached pin and forgets it.