---
title: "Discussion on \"Control 16 servos with Raspberry Pi + PCA9685 Driver\" | Hashnode"
description: "Discussion on \"Control 16 servos with Raspberry Pi + PCA9685 Driver\". In this post you will learn how to control up to 16 servos using the PCA9685 driver, raspberry pi and python library adafruit-circuitpython-servokit"
url: "https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Control 16 servos with Raspberry Pi + PCA9685 Driver](https://blog.garybricks.com/control-16-servos-with-raspberry-pi-pca9685-driver?utm_source=hashnode&utm_medium=feed)

In this post you will learn how to control up to 16 servos using the PCA9685 driver, raspberry pi and python library adafruit-circuitpython-servokit

Oct 7, 2021 · 2 min read · blog.garybricks.com  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#python3](https://hashnode.com/tag/python3)
-   [#python-projects](https://hashnode.com/tag/python-projects)
-   [#raspberry-pi](https://hashnode.com/tag/raspberry-pi)
-   [#robotics](https://hashnode.com/tag/robotics)

## Written by

[Gary Vladimir Núñez López](https://hashnode.com/@yragi-san117)

@yragi-san117 · Oaxaca, México

  
[View profile](https://hashnode.com/@yragi-san117)

Front End Software Developer

👋 Front-End Developer with a flair for competitive programming &amp; robotics. Expert in 3D CAD design, YouTube educator. Innovating from Oaxaca, México.

## Responses 4

Markdown supported · ⌘↵ to post

[ISDP Group 6](https://hashnode.com/@ISDPGroup6)

[Jul 22, 2022](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/62daea0399a21b6b5b5eb5b6)

I followed the steps, and the programme is able to execute without error, but no response from the servo. The external power for the PCA9685 is a 9V battery. I've checked the motor, and it's healthy. Any idea why the servo is not responding?

[Gary Vladimir Núñez López](https://hashnode.com/@yragi-san117)

[Jul 23, 2022](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/62daea0399a21b6b5b5eb5b6#reply-62db6edecf7a8a6d54f05eaa)

Hmmm, I'm not sure what the problem is, but the battery I used was a 5V not a 9V, maybe that's the problem?, also I recommend you to check the wiring, and try with the second library.

[Azam Usmani](https://hashnode.com/@azam336)

[Oct 24, 2025](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/62daea0399a21b6b5b5eb5b6#reply-68fb89411e73c591bd4c1feb)

hey hii did you manage to run the servo using pca and raspberry pi

[Pascal](https://hashnode.com/@metrowizard)

[Nov 29, 2021](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/61a4f5319ac0d611876b215e)

Very nice tutorial, thanks! I followed your steps above and it has thrown this exception on run:

```
/bin/python /home/pi/rover/Adafruit_Python_PCA9685/examples/simpletest.py

Traceback (most recent call last):
  File "/home/pi/rover/Adafruit_Python_PCA9685/examples/simpletest.py", line 56, in <module>
    kit.servo[7].angle = 175
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_servokit.py", line 147, in __getitem__
    servo = adafruit_motor.servo.Servo(self.kit._pca.channels[servo_channel])
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 89, in __init__
    super().__init__(pwm_out, min_pulse=min_pulse, max_pulse=max_pulse)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 29, in __init__
    self.set_pulse_width_range(min_pulse, max_pulse)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 33, in set_pulse_width_range
    self._min_duty = int((min_pulse * self._pwm_out.frequency) / 1000000 * 0xFFFF)
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_pca9685.py", line 56, in frequency
    return self._pca.frequency
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_pca9685.py", line 134, in frequency
    return self.reference_clock_speed / 4096 / self.prescale_reg
ZeroDivisionError: float division by zero
```

Could you help me? Thanks a lot in advance Metrowizard

[Gary Vladimir Núñez López](https://hashnode.com/@yragi-san117)

[Dec 2, 2021](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/61a4f5319ac0d611876b215e#reply-61a82767be456923c52bc57e)

Hi!, I'm glad you found the article useful, the error shown above has nothing to do with the adafruit library or hardware, the problem it's clear in the last line:

```
zeroDivisionError: float division by zero
```

that means that the code it's performing a division by zero which is not possible.

Have you changed the simplest.py file? in your code, I'm seeing lines that are not found in the original one.

Edit: I've checked the library and it says that it's' deprecated, maybe that has to do with the problem, either way, I recommend you skip that test and work with the second library I showed in the post, it's simpler and works better.

Hope this helps, let me know how you do.

[Pascal](https://hashnode.com/@metrowizard)

[Dec 2, 2021](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/61a4f5319ac0d611876b215e#reply-61a8c3bb723c3a712ae10db4)

[Gary Vladimir Núñez López](https://hashnode.com/@yragi-san117)

Hi! Thanks for your answer. I just repeated the tutorial with the second library (--> Adafruit\_CircuitPython\_ServoKit).

The same kind of error:

```
Traceback (most recent call last):
  File "/home/pi/rover/Main.py", line 35, in <module>
    test.test()
  File "/home/pi/rover/Controllers/ServoController.py", line 12, in test
    kit.servo[7].angle = 175
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_servokit.py", line 147, in __getitem__
    servo = adafruit_motor.servo.Servo(self.kit._pca.channels[servo_channel])
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 89, in __init__
    super().__init__(pwm_out, min_pulse=min_pulse, max_pulse=max_pulse)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 29, in __init__
    self.set_pulse_width_range(min_pulse, max_pulse)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_motor/servo.py", line 33, in set_pulse_width_range
    self._min_duty = int((min_pulse * self._pwm_out.frequency) / 1000000 * 0xFFFF)
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_pca9685.py", line 56, in frequency
    return self._pca.frequency
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_pca9685.py", line 134, in frequency
    return self.reference_clock_speed / 4096 / self.prescale_reg
ZeroDivisionError: float division by zero
```

I expect you have nothing different running than the stock Raspian? What version of python do you use? Python3.10? I have Python3.7 on the Raspberry Pi, and I do not know how to upgrade it to 3.10...

Your help would be VERY appreciated!

[Arquera1505](https://hashnode.com/@Arquera)

[Oct 27, 2021](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/6178d089913b6d3f08e15937)

Really nice project, I apreciate this!!

[Aristóteles Federico Núñez Juárez](https://hashnode.com/@sotsir)

[Oct 7, 2021](https://hashnode.com/posts/control-16-servos-with-raspberry-pi-pca9685-driver/615f4248b945c81a907cf1a0/comment/615f51edb945c81a907cf328)

Great article!, I like the way you explained it, keep the good work :)
