This example illustrates the use of simple stage machine to handle event within mbed. When any of the 3 push button is pressed, the stage (number) will be shown via the on-board LEDs. {{/media/uploads/yoonghm/state_machine_example.jpg}}
Revision 1:8cfb6bfdb4e0, committed 2011-12-08
- Comitter:
- yoonghm
- Date:
- Thu Dec 08 03:54:37 2011 +0000
- Parent:
- 0:8e509fb9a48c
- Commit message:
- Updated task and circuit diagram
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8e509fb9a48c -r 8cfb6bfdb4e0 main.cpp --- a/main.cpp Wed Dec 07 10:10:02 2011 +0000 +++ b/main.cpp Thu Dec 08 03:54:37 2011 +0000 @@ -23,7 +23,7 @@ void int_button3() {trigger |= 0x04;} /* task to be executed during each state transition */ -void do_task(int n) {task = n; wait(2.0); task = 0;} +void do_task(int n) {task = n; wait(2.0);} void sleep(void) {__WFI();} /* Power-saving sleeping mode */ @@ -42,6 +42,7 @@ /* initial the state machine */ state = STATE_A; + do_task(STATE_A); while(1) {