pca9685-rppal

Crates.iopca9685-rppal
lib.rspca9685-rppal
version0.1.0
created_at2025-01-27 11:40:35.92865+00
updated_at2025-01-27 11:40:35.92865+00
descriptionRaspberry Pi Wrapper for the Adafruit PCA9685 Servo/PWM Driver
homepage
repositoryhttps://github.com/BradenEverson/pca9685-rppal
max_upload_size
id1532336
size12,820
Braden Everson (BradenEverson)

documentation

README

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).
  • rppal crate (installed automatically as a dependency).

Installation

Add the following to your project's Cargo.toml:

[dependencies]
pca9685-rppal = "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 = Pca9685::new()?;
pca.init()?;
pca.set_pwm_freq(50.0)?;

pca.set_pwm(0, 0, 1500)?;
pca9685.set_all_pwm(0, 0)?;

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 :)

Commit count: 7

cargo fmt