Hello world code for PCA9955A class library. The PCA9955A is a 16-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 "PCA9955A.h" 00003 00004 // making an instance of PCA9955A (PCA9955A is cpmpatible to PCA9955B) 00005 PCA9955A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option) 00006 00007 // LED output instances in array 00008 LedPwmOutCC leds[] = { 00009 LedPwmOutCC ( led_cntlr, L0 ), // Instance for LED0 pin 00010 LedPwmOutCC ( led_cntlr, L1 ), // Instance for LED1 pin 00011 LedPwmOutCC ( led_cntlr, L2 ), // Instance for LED2 pin 00012 LedPwmOutCC ( led_cntlr, L3 ), // Instance for LED3 pin 00013 LedPwmOutCC ( led_cntlr, L4 ), // Instance for LED4 pin 00014 LedPwmOutCC ( led_cntlr, L5 ), // Instance for LED5 pin 00015 LedPwmOutCC ( led_cntlr, L6 ), // Instance for LED6 pin 00016 LedPwmOutCC ( led_cntlr, L7 ), // Instance for LED7 pin 00017 LedPwmOutCC ( led_cntlr, L8 ), // Instance for LED8 pin 00018 LedPwmOutCC ( led_cntlr, L9 ), // Instance for LED9 pin 00019 LedPwmOutCC ( led_cntlr, L10 ), // Instance for LED10 pin 00020 LedPwmOutCC ( led_cntlr, L11 ), // Instance for LED11 pin 00021 LedPwmOutCC ( led_cntlr, L12 ), // Instance for LED12 pin 00022 LedPwmOutCC ( led_cntlr, L13 ), // Instance for LED13 pin 00023 LedPwmOutCC ( led_cntlr, L14 ), // Instance for LED14 pin 00024 LedPwmOutCC ( led_cntlr, L15 ) // Instance for LED15 pin 00025 }; 00026 00027 int main() 00028 { 00029 for ( int i = 0; i < 16; i++ ) 00030 leds[ i ].current( 0.5 ); // LED output current set to 50% 00031 00032 while(1) { 00033 for ( int i = 0; i < 16; i++ ) { 00034 for ( float p = 1.0; p >= 0.0; p -= 0.01 ) { 00035 leds[ i ] = p; // set 'p' value into LED output instance 00036 wait( 0.01 ); 00037 } 00038 } 00039 } 00040 }
Generated on Wed Jul 13 2022 09:14:10 by 1.7.2