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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut myled1(LED1); 00004 DigitalOut myled2(LED2); 00005 DigitalOut myled3(LED3); 00006 DigitalOut myled4(LED4); 00007 00008 InterruptIn mybutton(USER_BUTTON); 00009 00010 double tempo = 0.3; // LED blinking delay 00011 00012 // Change LEDs blinking frequency 00013 void change_blinking_frequency() { 00014 if (tempo == 0.3) // If leds have low frequency 00015 tempo = 0.1; // Set the fast frequency 00016 else // If leds have fast frequency 00017 tempo = 0.3; // Set the low frequency 00018 } 00019 00020 int main() { 00021 // All LEDs are OFF 00022 myled1 = 0; 00023 myled2 = 0; 00024 myled3 = 0; 00025 myled4 = 0; 00026 00027 // Change LEDs blinking frequency when button is pressed 00028 mybutton.fall(&change_blinking_frequency); 00029 00030 while(1) { 00031 myled2 = 1; // LED2 is ON 00032 wait(tempo); // wait tempo 00033 myled2 = 0; // LED2 is OFF 00034 myled1 = 1; // LED1 is ON 00035 wait(tempo); // wait tempo 00036 myled1 = 0; // LED1 is OFF 00037 myled3 = 1; // LED3 is ON 00038 wait(tempo); // wait tempo 00039 myled3 = 0; // LED3 is OFF 00040 myled4 = 1; // LED4 is ON 00041 wait(tempo); // wait tempo 00042 myled4 = 0; // LED4 is OFF 00043 } 00044 }
Generated on Thu Jul 21 2022 05:54:16 by
1.7.2