Using the Adafruit Library

The Python code for Adafruit's PWM/Servo breakout on the Pi is available on Github at

This code should be a good starting point to understanding how you can access SMBus/I2C devices with your Pi, and getting things moving with your PWM/Servo breakout.

Downloading the Code from Github

The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using 'git', which is installed by default on most distros.  Simply run the following commands from an appropriate location (ex. "/home/pi"):
sudo apt-get install git build-essential python-dev
cd ~
git clone
cd Adafruit_Python_PCA9685
sudo python install 
# if you have python3 installed:
sudo python3 install 

Testing the Library

Once the code has be downloaded to an appropriate folder, and you have your PWM/Servo breakout and motor properly connected, you can test it out with the following command (the driver includes a simple demo program): 

cd examples
sudo python
To stop the example, simple press CTRL+C.

Depending on if you are using a standard or continuous rotation servo, you should get results similar to the following (a continuous rotation servo is being used in this particular example):
This guide was first published on Aug 16, 2012. It was last updated on Nov 20, 2018. This page (Using the Adafruit Library) was last updated on Feb 04, 2018.