Adafruit PCA9685 PWM Servo Driver Arduino Library
Public Member Functions | List of all members
Adafruit_PWMServoDriver Class Reference

Class that stores state and functions for interacting with PCA9685 PWM chip. More...

#include <Adafruit_PWMServoDriver.h>

Public Member Functions

 Adafruit_PWMServoDriver (uint8_t addr=0x40)
 Instantiates a new PCA9685 PWM driver chip with the I2C address on the Wire interface. On Due we use Wire1 since its the interface on the 'default' I2C pins. More...
 
 Adafruit_PWMServoDriver (TwoWire *I2C, uint8_t addr=0x40)
 Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface. More...
 
void begin (void)
 Setups the I2C interface and hardware.
 
void reset (void)
 Sends a reset command to the PCA9685 chip over I2C.
 
void setPWMFreq (float freq)
 Sets the PWM frequency for the entire chip, up to ~1.6 KHz. More...
 
void setPWM (uint8_t num, uint16_t on, uint16_t off)
 Sets the PWM output of one of the PCA9685 pins. More...
 
void setPin (uint8_t num, uint16_t val, bool invert=false)
 Helper to set pin PWM output. Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on. Optional invert parameter supports inverting the pulse for sinking to ground. More...
 

Detailed Description

Class that stores state and functions for interacting with PCA9685 PWM chip.

Constructor & Destructor Documentation

◆ Adafruit_PWMServoDriver() [1/2]

Adafruit_PWMServoDriver::Adafruit_PWMServoDriver ( uint8_t  addr = 0x40)

Instantiates a new PCA9685 PWM driver chip with the I2C address on the Wire interface. On Due we use Wire1 since its the interface on the 'default' I2C pins.

Parameters
addrThe 7-bit I2C address to locate this chip, default is 0x40

◆ Adafruit_PWMServoDriver() [2/2]

Adafruit_PWMServoDriver::Adafruit_PWMServoDriver ( TwoWire *  i2c,
uint8_t  addr = 0x40 
)

Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface.

Parameters
i2cA pointer to a 'Wire' compatible object that we'll use to communicate with
addrThe 7-bit I2C address to locate this chip, default is 0x40

Member Function Documentation

◆ setPWMFreq()

void Adafruit_PWMServoDriver::setPWMFreq ( float  freq)

Sets the PWM frequency for the entire chip, up to ~1.6 KHz.

Parameters
freqFloating point frequency that we will attempt to match

◆ setPWM()

void Adafruit_PWMServoDriver::setPWM ( uint8_t  num,
uint16_t  on,
uint16_t  off 
)

Sets the PWM output of one of the PCA9685 pins.

Parameters
numOne of the PWM output pins, from 0 to 15
onAt what point in the 4096-part cycle to turn the PWM output ON
offAt what point in the 4096-part cycle to turn the PWM output OFF

◆ setPin()

void Adafruit_PWMServoDriver::setPin ( uint8_t  num,
uint16_t  val,
bool  invert = false 
)

Helper to set pin PWM output. Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on. Optional invert parameter supports inverting the pulse for sinking to ground.

Parameters
numOne of the PWM output pins, from 0 to 15
valThe number of ticks out of 4096 to be active, should be a value from 0 to 4095 inclusive.
invertIf true, inverts the output, defaults to 'false'

The documentation for this class was generated from the following files: