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.


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)
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)
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)
Page last edited December 04, 2016
Text editor powered by tinymce.