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 /*Program Example 3.3: Flashes one of two LEDs, depending on the state of a 2-way switch 00002 */ 00003 #include "mbed.h" 00004 DigitalOut redled(p5); 00005 DigitalOut greenled(p6); 00006 DigitalIn switchinput(p7); 00007 int main() 00008 { 00009 while(1) { 00010 if (switchinput==1) { //test value of switchinput 00011 //execute following block if switchinput is 1 00012 greenled = 0; //green led is off 00013 redled = 1; // flash red led 00014 wait(0.2); 00015 redled = 0; 00016 wait(0.2); 00017 } //end of if 00018 else { //here if switchinput is 0 00019 redled = 0; //red led is off 00020 greenled = 1; // flash green led 00021 wait(0.2); 00022 greenled = 0; 00023 wait(0.2); 00024 } //end of else 00025 } //end of while(1) 00026 } //end of main 00027
Generated on Tue Jul 12 2022 21:47:53 by
1.7.2