Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@5:e2ad761c8570, 2022-06-16 (annotated)
- Committer:
- nxp_ip
- Date:
- Thu Jun 16 23:39:18 2022 +0000
- Revision:
- 5:e2ad761c8570
- Parent:
- 3:a67c21ad4173
- Child:
- 6:9abd0b582c2c
to check all output channels working
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nxp_ip | 2:cfa5103184b1 | 1 | #include "mbed.h" |
| nxp_ip | 2:cfa5103184b1 | 2 | #include "PCA9955A.h" |
| nxp_ip | 2:cfa5103184b1 | 3 | |
| nxp_ip | 3:a67c21ad4173 | 4 | PCA9955A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option) |
| nxp_ip | 5:e2ad761c8570 | 5 | |
| nxp_ip | 5:e2ad761c8570 | 6 | LedPwmOutCC leds[] = { |
| nxp_ip | 5:e2ad761c8570 | 7 | LedPwmOutCC ( led_cntlr, L0 ), // Instance for LED0 pin |
| nxp_ip | 5:e2ad761c8570 | 8 | LedPwmOutCC ( led_cntlr, L1 ), // Instance for LED1 pin |
| nxp_ip | 5:e2ad761c8570 | 9 | LedPwmOutCC ( led_cntlr, L2 ), // Instance for LED2 pin |
| nxp_ip | 5:e2ad761c8570 | 10 | LedPwmOutCC ( led_cntlr, L3 ), // Instance for LED3 pin |
| nxp_ip | 5:e2ad761c8570 | 11 | LedPwmOutCC ( led_cntlr, L4 ), // Instance for LED4 pin |
| nxp_ip | 5:e2ad761c8570 | 12 | LedPwmOutCC ( led_cntlr, L5 ), // Instance for LED5 pin |
| nxp_ip | 5:e2ad761c8570 | 13 | LedPwmOutCC ( led_cntlr, L6 ), // Instance for LED6 pin |
| nxp_ip | 5:e2ad761c8570 | 14 | LedPwmOutCC ( led_cntlr, L7 ), // Instance for LED7 pin |
| nxp_ip | 5:e2ad761c8570 | 15 | LedPwmOutCC ( led_cntlr, L8 ), // Instance for LED8 pin |
| nxp_ip | 5:e2ad761c8570 | 16 | LedPwmOutCC ( led_cntlr, L9 ), // Instance for LED9 pin |
| nxp_ip | 5:e2ad761c8570 | 17 | LedPwmOutCC ( led_cntlr, L10 ), // Instance for LED10 pin |
| nxp_ip | 5:e2ad761c8570 | 18 | LedPwmOutCC ( led_cntlr, L11 ), // Instance for LED11 pin |
| nxp_ip | 5:e2ad761c8570 | 19 | LedPwmOutCC ( led_cntlr, L12 ), // Instance for LED12 pin |
| nxp_ip | 5:e2ad761c8570 | 20 | LedPwmOutCC ( led_cntlr, L13 ), // Instance for LED13 pin |
| nxp_ip | 5:e2ad761c8570 | 21 | LedPwmOutCC ( led_cntlr, L14 ), // Instance for LED14 pin |
| nxp_ip | 5:e2ad761c8570 | 22 | LedPwmOutCC ( led_cntlr, L15 ) // Instance for LED15 pin |
| nxp_ip | 5:e2ad761c8570 | 23 | }; |
| nxp_ip | 2:cfa5103184b1 | 24 | |
| nxp_ip | 2:cfa5103184b1 | 25 | int main() |
| nxp_ip | 2:cfa5103184b1 | 26 | { |
| nxp_ip | 5:e2ad761c8570 | 27 | for ( int i = 0; i < 16; i++ ) |
| nxp_ip | 5:e2ad761c8570 | 28 | leds[ i ].current( 0.5 ); // LED pin current output setting to 50% |
| nxp_ip | 2:cfa5103184b1 | 29 | |
| nxp_ip | 2:cfa5103184b1 | 30 | while(1) { |
| nxp_ip | 5:e2ad761c8570 | 31 | for ( int i = 0; i < 16; i++ ) |
| nxp_ip | 5:e2ad761c8570 | 32 | { |
| nxp_ip | 5:e2ad761c8570 | 33 | for ( float p = 1.0; p >= 0.0; p -= 0.01 ) { |
| nxp_ip | 5:e2ad761c8570 | 34 | leds[ i ] = p; // Set LED0 output PWM dutycycle as 'p' |
| nxp_ip | 5:e2ad761c8570 | 35 | wait( 0.01 ); |
| nxp_ip | 5:e2ad761c8570 | 36 | } |
| nxp_ip | 5:e2ad761c8570 | 37 | } |
| nxp_ip | 2:cfa5103184b1 | 38 | } |
| nxp_ip | 2:cfa5103184b1 | 39 | } |
PCA9955B, PCA9956B : 16 & 24-channel constant current LED driver