Mario Simaremare
/
mbed_blinky_with_switch
tutorial to use a single swith.
Revision 0:ea82f5a7a1fc, committed 2016-05-31
- Comitter:
- mariosimaremare
- Date:
- Tue May 31 10:05:33 2016 +0000
- Commit message:
- Initial commit.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 31 10:05:33 2016 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +DigitalOut redled(LED1); +DigitalOut greenled(LED2); +DigitalIn switchinput(p7); + +int main() +{ + while(1) { + if (switchinput==1) { //test value of switchinput + //execute following block if switchinput is 1 + greenled = 0; //green led is off + redled = 1; // flash red led + wait(0.2); + redled = 0; + wait(0.2); + } //end of if + else { //here if switchinput is 0 + redled = 0; //red led is off + greenled = 1; // flash green led + wait(0.2); + greenled = 0; + wait(0.2); + } //end of else + } //end of while(1) +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 31 10:05:33 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file