LEDDriver_NXP_Arduino 0.1.2
LED driver device operation sample code for Arduino
|
LED driver device operation sample code for Arduino
Note
This library works with I2C_device
library together. Please be sure the I2C_device
library is imported in your environment before trying to build.
PCA9955BTW-ARD (left), PCA9957HN-ARD (right) and OM13321 LED driver evaluation boards
An Arduino library for I²C LED drivers with sample code.
The I²C temperature sensors can measure temoperature and output comparator or interrupt signals by threshold settings.
Type# | Features | # of channels | additional feature | Interface | Evaluation board |
---|---|---|---|---|---|
PCA9955B | Constant current LED driver | 16ch | with gradation control | I²C Fast-mode plus (1MHz) | PCA9955BTW-ARD LED Driver Arduino® Shield Evaluation Board |
PCA9956B | Constant current LED driver | 24ch | — | I²C Fast-mode plus (1MHz) | OM13321 |
PCA9957 | Constant current LED driver | 24ch | with gradation control | SPI | PCA9957HN-ARD LED Driver Arduino® Shield Evaluation Board |
To put PCA9957HN-ARD Arduino-shield evaluation board, use socket-pin extenders to avoid down side connector interfare.
With LEDDriver_NXP_Arduino
library, the LEDs can be managed simple API.
For PCA9955B and PCA9956B, those operations are quite similar. When the device is changed, just overwrite class name from PCA9955B
to PCA9956B
.
For PCA9957, it uses an SPI as serial interface. To use the SPI, need to have SPI.begin()
in setup()
function.
For importing library and run the sample code, please find Getting started page (README.md) of TempSensor_NXP_Arduino.
PCA9955B
, PCA9956B
and PCA9957
class libraries are included. Those libraries can be used by just making an instance from those class.
Those libraries have common methods to get/set device information.
Method | Role |
---|---|
begin( float current = 0.1, board env = NONE ) | Initializing device. 1st argument current is ratio of output current. 0.0~1.0. 2nd argument env is an option: use LEDDriver::ARDUINO_SHIELD if the target board is Arduino-shield board |
pwm( uint8_t ch, float value ) | Set single channel LED brightness. value must be in float: 0.0~1.0 |
void pwm( float* values ) | Set LED brightness for all channels. values must be an array of float with length of number of device output channels. Each float values in the array should be 0.0~1.0. |
Example code is provided as scketch files.
For a quick access to those sketch, refer to last step of **"Getting started" section** of TempSensor_NXP_Arduino page (README.md).
Sketch | Target | Feature |
---|---|---|
PCA9955B_simple_ch0 | PCA9955B | Simple sample for just blinking channel 0 |
PCA9955B_all_channels | PCA9955B | Simple operation to blink all channels in order |
PCA9955B_direct_register_access | PCA9955B | Direct register access sample. Write/read a register in every 100 mili-second |
PCA9955B_color_phases | PCA9955B | Phase independent dimming on color LEDs: color mixing |
PCA9956B_simple_ch0 | PCA9956B | Simple sample for just blinking channel 0 |
PCA9956B_all_channels | PCA9956B | Simple operation to blink all channels in order |
PCA9956B_direct_register_access | PCA9956B | Direct register access sample. Write/read a register in every 100 mili-second |
PCA9956B_color_phases | PCA9956B | Phase independent dimming on color LEDs: color mixing |
PCA9957_simple_ch0 | PCA9957 | Simple sample for just blinking channel 0 |
PCA9957_all_channels | PCA9957 | Simple operation to blink all channels in order |
PCA9957_direct_register_access | PCA9957 | Direct register access sample. Write/read a register in every 100 mili-second |
PCA9957_color_phases | PCA9957 | Phase independent dimming on color LEDs: color mixing |
zzz_no_library_operation_sample | PCA9955B | Showing a sample of no-library using operation |
For details of the library, please find descriptions in this document.
Library | Feature | Target devices | Required library |
---|---|---|---|
LEDDriver_NXP_Arduino | LED driver libraries | PCA9955B, PCA9956B, PCA9957 | I2C_device_Arduino |
TempSensor_NXP_Arduino | Temperature sensor libraries | LM75B, PCT2075, P3T1085 | I2C_device_Arduino |
I2C_device_Arduino | Base library for I²C operations | none (can be applied as base class for all I²C targets) | — |