Hello world code for PCA9956A class library. The PCA9956A is a 24-channel Fm+ I2C-bus 57mA/20V constant current LED driver. This program shows its basic operation of PWM and current settings.
main.cpp
00001 #include "mbed.h" 00002 #include "PCA9956A.h" 00003 00004 PCA9956A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option) 00005 LedPwmOutCC led0( led_cntlr, L0 ); // Instance for LED0 pin 00006 LedPwmOutCC led1( led_cntlr, L1 ); // Instance for LED1 pin 00007 LedPwmOutCC led2( led_cntlr, L2 ); // Instance for LED2 pin 00008 00009 int main() 00010 { 00011 led0.current( 0.5 ); // LED0 pin current output setting to 50% 00012 led1.current( 0.5 ); // LED1 pin current output setting to 50% 00013 led2.current( 0.5 ); // LED2 pin current output setting to 50% 00014 00015 while(1) { 00016 00017 for ( float p = 1.0; p >= 0.0; p -= 0.01 ) { 00018 led0 = p; // Set LED0 output PWM dutycycle as 'p' 00019 wait( 0.01 ); 00020 } 00021 00022 for ( float p = 1.0; p >= 0.0; p -= 0.01 ) { 00023 led1 = p; // Set LED1 output PWM dutycycle as 'p' 00024 wait( 0.01 ); 00025 } 00026 00027 for ( float p = 1.0; p >= 0.0; p -= 0.01 ) { 00028 led2 = p; // Set LED2 output PWM dutycycle as 'p' 00029 wait( 0.01 ); 00030 } 00031 } 00032 }
Generated on Tue Jul 12 2022 17:18:23 by 1.7.2