copy 1
Dependencies: mbed
Revision 0:7eee9280f29f, committed 2017-10-24
- Comitter:
- motley
- Date:
- Tue Oct 24 14:52:59 2017 +0000
- Commit message:
- copy 1
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 7eee9280f29f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 24 14:52:59 2017 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#define N 1000000 +#define RELEASED 0 +#define PRESSED 1 + +//Hardware objects +DigitalOut red_led(PE_15); //CountUp is in its critical section +DigitalOut yellow_led(PB_10); //CountDown is in its critical section +DigitalOut green_led(PB_11); //counter != 0 +DigitalOut onboardLED(LED1); + +DigitalIn button(USER_BUTTON); +DigitalIn sw1(PE_12); +DigitalIn sw2(PE_14); + +//The code below is hugely flawed and is only to +//illustrate the problem of blocking hardware +int main() { + + //Light up + red_led = 1; + yellow_led = 1; + green_led = 1; + onboardLED = 1; + + //Now loop forever + while(1) { + + while (sw1 == RELEASED) {}; + wait(0.2); + while (sw1 == PRESSED) {}; + red_led = !red_led; + wait(0.2); + + while (sw2 == RELEASED) {}; + wait(0.2); + while (sw2 == PRESSED) {}; + green_led = !green_led; + wait(0.2); + + //Flash the yellow + yellow_led = !yellow_led; + wait(0.5); + }; +}
diff -r 000000000000 -r 7eee9280f29f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 24 14:52:59 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/b484a57bc302 \ No newline at end of file