Skip to content

C++ and Python library for PCA9685 chips and the Raspberry Pi

License

Notifications You must be signed in to change notification settings

barulicm/PiPCA9685

Repository files navigation

PiPCA9685

PiPCA9685 provides an interface for controlling a PCA9685 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 did not provide.

Installation

  1. Before you begin, make sure your Pi has I2C enabled.

    This step is not needed when using Ubuntu.

    1. Run sudo raspi-config
    2. Select "Interfacing Options"
    3. Enable I2C automatic loading
  2. Clone repo

    git clone https://github.com/barulicm/PiPCA9685.git
  3. Install dependencies from apt

    cd PiPCA9685
    xargs -a apt_dependencies.txt sudo apt-get install -y

    Note: On Ubuntu, you may need to enable the universe repostiory with the command below to find some of the needed packages. This is NOT needed on Raspberry Pi OS.

    sudo add-apt-repository universe
  4. Build and install library

    sudo cmake --workflow --preset install

You can uninstall the library with this CMake command:

sudo cmake --workflow --preset uninstall

Examples

You can find simple examples of how to use this library in C++ and Python in the examples directory.

C++

To build and run the C++ example, run the following commands in the examples/cpp/ directory.

cmake --workflow --preset build
./build/example-cpp

Python

To run the Python example, run the following command in the examples/python/ directory.

python3 example.py

About

C++ and Python library for PCA9685 chips and the Raspberry Pi

Resources

License

Stars

Watchers

Forks