PCA9685 Class
- ID: pca9685
- Name: I2C 16-channel 12-bit PWM LED Controller
- Category: led motor
- Manufacturer: adafruit
- Link: http://www.adafruit.com/products/815
- Connection: i2c
This controller is also used on the Adafruit* Motor Shield v2.3 board to control up to 4 DC motors, 2 stepper motors, and 2 servo motors.
This module was tested with the Adafruit Motor Shield v2.3
Item Index
Methods
Properties
- REG_MODE1
- REG_MODE2
- REG_I2C_SA1
- REG_I2C_SA2
- REG_I2C_SA3
- REG_ALLCALL
- REG_LED0_ON_L
- REG_LED0_ON_H
- REG_LED0_OFF_L
- REG_LED0_OFF_H
- REG_LED1_ON_L
- REG_LED1_ON_H
- REG_LED1_OFF_L
- REG_LED1_OFF_H
- REG_LED2_ON_L
- REG_LED2_ON_H
- REG_LED2_OFF_L
- REG_LED2_OFF_H
- REG_LED3_ON_L
- REG_LED3_ON_H
- REG_LED3_OFF_L
- REG_LED3_OFF_H
- REG_LED4_ON_L
- REG_LED4_ON_H
- REG_LED4_OFF_L
- REG_LED4_OFF_H
- REG_LED5_ON_L
- REG_LED5_ON_H
- REG_LED5_OFF_L
- REG_LED5_OFF_H
- REG_LED6_ON_L
- REG_LED6_ON_H
- REG_LED6_OFF_L
- REG_LED6_OFF_H
- REG_LED7_ON_L
- REG_LED7_ON_H
- REG_LED7_OFF_L
- REG_LED7_OFF_H
- REG_LED8_ON_L
- REG_LED8_ON_H
- REG_LED8_OFF_L
- REG_LED8_OFF_H
- REG_LED9_ON_L
- REG_LED9_ON_H
- REG_LED9_OFF_L
- REG_LED9_OFF_H
- REG_LED10_ON_L
- REG_LED10_ON_H
- REG_LED10_OFF_L
- REG_LED10_OFF_H
- REG_LED11_ON_L
- REG_LED11_ON_H
- REG_LED11_OFF_L
- REG_LED11_OFF_H
- REG_LED12_ON_L
- REG_LED12_ON_H
- REG_LED12_OFF_L
- REG_LED12_OFF_H
- REG_LED13_ON_L
- REG_LED13_ON_H
- REG_LED13_OFF_L
- REG_LED13_OFF_H
- REG_LED14_ON_L
- REG_LED14_ON_H
- REG_LED14_OFF_L
- REG_LED14_OFF_H
- REG_LED15_ON_L
- REG_LED15_ON_H
- REG_LED15_OFF_L
- REG_LED15_OFF_H
- REG_ALL_LED_ON_L
- REG_ALL_LED_ON_H
- REG_ALL_LED_OFF_L
- REG_ALL_LED_OFF_H
- REG_PRESCALE
- REG_TESTMODE
- MODE1_ALL_CALL
- MODE1_SUB3
- MODE1_SUB2
- MODE1_SUB1
- MODE1_SLEEP
- MODE1_AI
- MODE1_EXTCLK
- MODE1_RESTART
- MODE2_OUTNE0
- MODE2_OUTNE
- MODE2_OUTDRV
- MODE2_OCH
- MODE2_INVRT
- MODE2_RESERVE0
- MODE2_RESERVE1
- MODE2_RESERVE2
Methods
PCA9685
-
bus
-
address
-
raw
PCA9685 constructor
Parameters:
-
bus
NumberI2C bus to use
-
address
NumberAddress for this device
-
raw
Booleanundefined
Returns:
writeByte
-
reg
-
byte
Writes a byte value into a register
Parameters:
-
reg
NumberRegister location to write into
-
byte
NumberByte to write
Returns:
True if successful
writeWord
-
reg
-
word
Writes a word value into a register. Note: the device must have the auto-increment bit set in the MODE1 register to work.
Parameters:
-
reg
NumberRegister location to write into
-
word
NumberWord to write
Returns:
True if successful
readByte
-
reg
Reads a byte value from a register
Parameters:
-
reg
NumberRegister location to read from
Returns:
Value in a specified register
readWord
-
reg
Reads a word value from a register. Note: the device must have the auto-increment bit set in the MODE1 register to work.
Parameters:
-
reg
NumberRegister location to read from
Returns:
Value in a specified register
setModeSleep
-
sleep
Puts the device in or out of the sleep mode. The device is always in the sleep mode upon power-up.
Parameters:
-
sleep
BooleanTrue to put the device in the sleep mode, false to put out
Returns:
True if successful
ledFullOn
-
led
-
val
Sets or clears the FULL ON bit for a given LED
Parameters:
-
led
NumberLED number; valid values are 0-15, PCA9685_ALL_LED
-
val
BooleanTrue to set the bit, false to clear it
Returns:
True if successful
ledFullOff
-
led
-
val
Sets or clears the FULL OFF bit for a given LED. If the FULL ON bit is also set, FULL OFF has precedence.
Parameters:
-
led
NumberLED number; valid values are 0-15, PCA9685_ALL_LED
-
val
BooleanTrue to set the bit, false to clear it
Returns:
True if successful
ledOnTime
-
led
-
time
Sets the 'LED on' time (0-4,095). See the PCA9685 datasheet for details.
Parameters:
-
led
NumberLED number; valid values are 0-15, PCA9685_ALL_LED
-
time
Number12-bit value at which point the LED turns on
Returns:
True if successful
ledOffTime
-
led
-
time
Sets the 'LED off' time (0-4,095). See the PCA9685 datasheet for details.
Parameters:
-
led
NumberLED number; valid values are 0-15, PCA9685_ALL_LED
-
time
Number12-bit value at which point the LED turns off
Returns:
True if successful
setPrescale
-
prescale
Sets the prescale value. See the PCA9685 datasheet for details. The prescale can only be set when the device is in the sleep mode.
Parameters:
-
prescale
NumberPrescale value
Returns:
True if successful
setPrescaleFromHz
-
hz
-
oscFreq
Sets the prescale value based on a desired frequency in Hz. The prescale can only be set when the device is in the sleep mode.
Parameters:
-
hz
NumberDesired frequency in Hz
-
oscFreq
NumberOscillator frequency; default is 25 MHz
Returns:
True if successful
enableRestart
-
enabled
Enables or disables the restart capability of the controller
Parameters:
-
enabled
BooleanTrue to enable, false to disable It is enabled by default.