PiPCA9685 provides an interface for controlling a PCA8695 chip from a Raspberry Pi in C++ and Python.
This library was originally designed to control servos with Adafruit's PWM Hat. It was born out of a desire for C++ bindings, which Adafruit's library lacks.
-
Before you begin, make sure your Pi has I2C enabled.
- Run
sudo raspi-config
- Select "Interfacing Options"
- Enable I2C automatic loading
- Run
-
Clone repo
git clone https://github.com/barulicm/PiPCA9685.git
-
Install dependencies from apt
cd PiPCA9685 xargs -a apt_dependencies.txt sudo apt-get install -y
-
Finally, build and install the library
cmake -B build cmake --build build sudo cmake --install build cmake --build build --target install_python
NOTE: PiPCA9685 will default to installing the Python library for Python 3. If you'd like to use a different version, you can specify the version in the call to cmake.
cmake -DPYBIND11_PYTHON_VERIONS 2.7 ..
You can find simple examples of how to use this library in C++ and Python in the examples directory.
To build and run the C++ example, run the following commands in the examples/cpp/
directory.
cmake -B build
cmake --build build
./build/example-cpp
To run the Python example, run the following command in the examples/python/
directory.
python3 example.py