Simon Ford
/
Toggle
Simple program showing code running based on switch position/pin state
Revision 0:0ad077525ca2, committed 2012-06-10
- Comitter:
- simon
- Date:
- Sun Jun 10 07:36:07 2012 +0000
- Commit message:
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 |
diff -r 000000000000 -r 0ad077525ca2 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jun 10 07:36:07 2012 +0000 @@ -0,0 +1,26 @@ +// run some code based on switching a switch (changing a pin state) + +#include "mbed.h" + +DigitalIn toggle(p5); +DigitalOut myled(LED1); + +void toggle_on() { + for(int i=0; i<10; i++) { + myled = !myled; + wait(0.2); + } +} + +void toggle_off() { + // do nothing +} + +int main() { + while(1) { + while(!toggle); // wait while toggle == 0 + toggle_on(); + while(toggle); // wait while toggle == 1 + toggle_off(); + } +}
diff -r 000000000000 -r 0ad077525ca2 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jun 10 07:36:07 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479