PCA9685 Class

The PCA9685 Class provides a programming interface to the PCA9685 I2C PWM/Servo driver chip.

The PCA9685 is used in the Adafruit DC&Stepper Motor Hat and in the adafruit 16-channel 12-bit PWM/Servo Driver breakout.

Adafruit DC & Stepper Motor HAT for Raspberry Pi - Mini Kit

PRODUCT ID: 2348
Let your robotic dreams come true with the new DC+Stepper Motor HAT from Adafruit. This Raspberry Pi add-on is perfect for any motion project as it can drive up to 4 DC or 2 Stepper...
$22.50
IN STOCK

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface

PRODUCT ID: 815
You want to make a cool robot, maybe a hexapod walker, or maybe just a piece of art with a lot of moving parts. Or maybe you want to drive a lot of LEDs with precise PWM output. Then you...
$14.95
IN STOCK

Constructors

The PCA9685 Class has a single constructor. The constructor takes an optional argument of an I2C address. I2C addresses for the chip are in the range 0x40 to 0x7F.

If no argument is provided the constructor configures the class to use the default I2C address of 0x40.

The PCA9685 class references the I2CBase class as superclass.  The I2C address in the constructor is passed to the superclass

public PCA9685(int addr = PCA9685_ADDRESS) : base (addr)

Methods

InitPCA9685Async

This is an asynchronous method which initializes the I2C interface by calling the I2CBase Class InitI2CAsync method, and resets the chip

The I2CSpeed enumeration is inherited from I2CBase.

public async Task InitPCA9685Async(I2CSpeed i2cSpeed = I2CSpeed.I2C_100kHz)

Reset

Resets the PCA9685

public void Reset()

SetPWMFrequency

Sets the PWM frequency of the PCA9685. Takes a single argument of type double, in the range of 0.0 to 4095.0.

public void SetPWMFrequency(double freq)

SetPWM

Sets the PWM on a specified pin. Arguments are the pin number, the on time, and the off time.

public void SetPWM(int num, ushort on, ushort off)

SetAllPWM

Sets a PWM on all pins. Arguments are the on time and the off time.

public void SetAllPWM(ushort on, ushort off)

SetPin

Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off. Optional invert parameter supports inverting the pulse for sinking to ground. Parameters are pin number, PWM value, and a boolean invert.

PWM value should be from 0 to 4095 inclusive

public void SetPin(int num, ushort val, bool invert)
Last updated on 2016-12-04 at 02.11.38 PM Published on 2016-11-22 at 01.26.46 PM