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 00003 PwmOut myled1(LED1); 00004 PwmOut myled2(LED2); 00005 PwmOut myled3(LED3); 00006 PwmOut myled4(LED4); 00007 00008 PwmOut * leds[4]; 00009 00010 int main() { 00011 leds[0] = &myled1; 00012 leds[1] = &myled2; 00013 leds[2] = &myled3; 00014 leds[3] = &myled4; 00015 00016 float level = 0; 00017 float increment = 0.01; 00018 int which = 0; 00019 00020 while(1) { 00021 level += increment; 00022 00023 if( level >= 1 ) { 00024 *(leds[which]) = 1; 00025 which++; 00026 if( which > 3 ) { 00027 which = 3; 00028 increment = -0.01; 00029 wait(0.5); 00030 } 00031 else { 00032 level = 0; 00033 } 00034 } 00035 else if( level <= 0 ) { 00036 *(leds[which]) = 0; 00037 which--; 00038 if( which < 0 ) { 00039 which = 0; 00040 increment = 0.01; 00041 wait(0.5); 00042 } 00043 else { 00044 level = 0.999; 00045 } 00046 } 00047 00048 *(leds[which]) = level; 00049 wait(0.01); 00050 } 00051 }
Generated on Sat Apr 1 2023 06:41:40 by
