Hello world code for PCA9622 class library. The PCA9622 is a 16-channel Fm+ I2C-bus 100mA/40 V LED driver. This program shows its basic operation of PWM output.

Dependencies:   PCA962x mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "PCA9622.h"
00003 
00004 PCA9622     led_cntlr( p28, p27, 0x3E );    //  SDA, SCL, Slave_address(option)
00005 LedPwmOut   led0( led_cntlr, L0  );         //  Instance for LED0 pin
00006 LedPwmOut   led1( led_cntlr, L1  );         //  Instance for LED1 pin
00007 LedPwmOut   led2( led_cntlr, L2  );         //  Instance for LED2 pin
00008 
00009 int main()
00010 {
00011     while(1) {
00012 
00013         for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
00014             led0    = p;    //  Set LED0 output PWM dutycycle as 'p'
00015             wait( 0.01 );
00016         }
00017 
00018         for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
00019             led1    = p;    //  Set LED1 output PWM dutycycle as 'p'
00020             wait( 0.01 );
00021         }
00022 
00023         for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
00024             led2    = p;    //  Set LED2 output PWM dutycycle as 'p'
00025             wait( 0.01 );
00026         }
00027     }
00028 }