adafruit_servokit
¶
CircuitPython helper library for the PWM/Servo FeatherWing, Shield and Pi HAT and Bonnet kits.
- Author(s): Kattni Rembor
Implementation Notes¶
Hardware:
- 8-Channel PWM or Servo FeatherWing
- Adafruit 16-Channel 12-bit PWM/Servo Shield
- Adafruit 16-Channel PWM/Servo HAT for Raspberry Pi
- Adafruit 16-Channel PWM/Servo Bonnet for Raspberry Pi
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- Adafruit’s PCA9685 library: https://github.com/adafruit/Adafruit_CircuitPython_PCA9685
- Adafruit’s Motor library: https://github.com/adafruit/Adafruit_CircuitPython_Motor
-
class
adafruit_servokit.
ServoKit
(*, channels, i2c=None, address=64, reference_clock_speed=25000000, frequency=50)¶ Class representing an Adafruit PWM/Servo FeatherWing, Shield or Pi HAT and Bonnet kits.
Automatically uses the I2C bus on a Feather, Metro or Raspberry Pi.
Initialise the PCA9685 chip at
address
.The internal reference clock is 25MHz but may vary slightly with environmental conditions and manufacturing variances. Providing a more precise
reference_clock_speed
can improve the accuracy of the frequency and duty_cycle computations. See thecalibration.py
example in the PCA9685 GitHub repo for how to derive this value by measuring the resulting pulse widths.Parameters: - channels (int) – The number of servo channels available. Must be 8 or 16. The FeatherWing has 8 channels. The Shield, HAT, and Bonnet have 16 channels.
- address (int) – The I2C address of the PCA9685. Default address is
0x40
. - reference_clock_speed (int) – The frequency of the internal reference clock in Hertz.
Default reference clock speed is
25000000
. - frequency (int) – The overall PWM frequency of the PCA9685 in Hertz.
Default frequency is
50
.
-
continuous_servo
¶ ContinuousServo
controls for continuous rotation servos.This FeatherWing example rotates a continuous rotation servo on channel
0
forward for one second, then backward for one second, and then stops the rotation.import time from adafruit_servokit import ServoKit kit = ServoKit(channels=8) kit.continuous_servo[0].throttle = 1 time.sleep(1) kit.continuous_servo[0].throttle = -1 time.sleep(1) kit.continuous_servo[0].throttle = 0
-
servo
¶ Servo
controls for standard servos.This FeatherWing example rotates a servo on channel
0
to180
degrees for one second, and then returns it to0
degrees.import time from adafruit_servokit import ServoKit kit = ServoKit(channels=8) kit.servo[0].angle = 180 time.sleep(1) kit.servo[0].angle = 0