The example program for mbed pin-compatible platforms
Fork of mbed_blinky by
Revision 7:97872775e085, committed 2014-10-06
- Comitter:
- koji333
- Date:
- Mon Oct 06 16:54:04 2014 +0000
- Parent:
- 6:e8cd76f38fa9
- Commit message:
- First example which uses both digital input and digital output
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 |
--- a/main.cpp Fri May 09 19:58:03 2014 +0300 +++ b/main.cpp Mon Oct 06 16:54:04 2014 +0000 @@ -1,12 +1,23 @@ #include "mbed.h" -DigitalOut myled(LED1); - +DigitalIn diginput(p7); +DigitalOut led1(LED1); +DigitalOut led2(LED2); + /* + Wire a mechanical button so that it connects the pin 'p7' and GND. + Then pressing the mechanical button causes 'diginput' == 0. + The LED 'led1' lights while the mechanical button is not pressed. + The LED 'led2' blinks while the mechanical button is pressed. + */ int main() { while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + if(diginput) { // the mechanical button is not pressed. + led1 = 1; + led2 = 0; + } else { // the mechanical button is pressed. + led1 = 0; + led2 = !led2; + }; + wait(0.25); } }
--- a/mbed.bld Fri May 09 19:58:03 2014 +0300 +++ b/mbed.bld Mon Oct 06 16:54:04 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file