Project 1 – Python control of a PWM board driving RC servo motors

You should now have a reasonable understanding of what is required to program an I2C PWM board, so let's look at some Python code to drive the Adafruit 16 channel PWM board.


The python-smbus library is compatible only with Python 2 at the time of writing. To run PCA9685, you have to use IDLE and not IDLE3. To run from the command line, use Python and not Python 3. As with the RPi-GPIO library, the SMBus library needs to have root privileges.

First, create a new /home/pi/servo project directory for the files and download from the Chapter 6 folder at into the directory.

Then, open the file in the idle development environment, remembering ...

Get Raspberry Pi Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.