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
00001 #include "mbed.h" 00002 #include "PCA9532.h" 00003 00004 DigitalOut myled(LED1); 00005 00006 PCA9532 leds (p28,p27,0xc0); 00007 00008 int main() { 00009 00010 00011 // set leds 15-12 to PWM1 channel 00012 leds.pwm1(0xf000); 00013 00014 // set leds 11-8 to PWM0 channel 00015 leds.pwm0(0x0f00); 00016 00017 // set leds 7-4 to "off" 00018 leds.clear(0x00f0); 00019 00020 // set leds 7-4 to "on" 00021 leds.set(0xf); 00022 00023 00024 while (1) { 00025 00026 for (float i = 0.0 ; i < 1.0 ; i+=0.01) { 00027 leds.duty0(i); // PWM0 brighter 00028 leds.duty1(1.0-i); // PWM1 dimmer 00029 wait (0.01); 00030 } 00031 00032 leds.clear(0xf); // Toggle LEDS 00033 leds.set(0x00f0); 00034 00035 for (float i = 1.0 ; i > 0.0 ; i-=0.01) { 00036 leds.duty0(i); // PWM0 dimmer 00037 leds.duty1(1.0-i); // PWM1 brighter 00038 00039 wait (0.01); 00040 } 00041 00042 leds.clear(0x00f0); // Toggle LEDS 00043 leds.set(0x000f); 00044 00045 00046 00047 } 00048 00049 } 00050
Generated on Wed Aug 17 2022 18:23:48 by
1.7.2