Be sure you've turned on or plugged in the external 5V power supply to the PCA9685 board too!
First you'll need to import and initialize the ServoKit class. You must specify the number of channels available on your
board. The breakout has 16 channels, so when you create the class object, you will specify 16 .
Now you're ready to control both standard and continuous rotation servos.
Standard Servos
To control a standard servo, you need to specify the channel the servo is connected to. You can then control
movement by setting angle to the number of degrees.
For example to move the servo connected to channel 0 to 180 degrees:
Now that the PCA9685 is set up for servos lets make a Servo object so that we can adjust the servo based on angle
instead of duty_cycle.
By default the Servo class will use actuation range, minimum pulse-width, and maximum pulse-width values that should
work for most servos. However check the Servo class documentation (https://adafru.it/BNE) for more details on extra
parameters to customize the signal generated for your servos.
With Servo, you specify a position as an angle. The angle will always be between 0 and the actuation range given
when Servo was created. The default is 180 degrees but your servo might have a smaller sweep--change the total
angle by specifying the actuation_angle parameter in the Servo class initializer above.
Now set the angle to 180, one extreme of the range:
To return the servo to 0 degrees:
With a standard servo, you specify the position as an angle. The angle will always be between 0 and the actuation
range. The default is 180 degrees but your servo may have a smaller sweep. You can change the total angle by setting
actuation_range .
For example, to set the actuation range to 160 degrees: