PCA9685 RPPal
A rppal-based Rust library for interacting with the Adafruit PCA9685 16-channel PWM/Servo Driver on Raspberry Pi. This library wraps the lower-level I²C operations to simplify setting up the PCA9685 and controlling PWM channels.
Features
- Simple Initialization: Easily create and configure the PCA9685 device at its default I²C address (
0x40). - Frequency Control: Set the PWM frequency (in Hz) on all 16 channels simultaneously.
- Channel Control: Independently control each channel by specifying ON/OFF counts (0–4095).
- Bulk Control: Set PWM for all channels at once.
Getting Started
Prerequisites
- A Raspberry Pi with I²C enabled (see Raspberry Pi documentation for details).
- Rust (stable toolchain or later).
rppalcrate (installed automatically as a dependency).
Installation
Add the following to your project's Cargo.toml:
[]
= "0.1.0"
Usage
You can initialize a device, set the PWM frequency and control a single or all channels at once!
let mut pca = new?;
pca.init?;
pca.set_pwm_freq?;
pca.set_pwm?;
pca9685.set_all_pwm?;
Thanks
Special thanks to the rppal crate for acting as a base to this crate and to adafruit_pwm_servo_driver for generic implementation details :)