Realize the Ledfow
Dependencies: mbed
Fork of DigitalOut_HelloWorld by
Revision 3:743f42c80067, committed 2014-10-14
- Comitter:
- shiyilei
- Date:
- Tue Oct 14 02:05:10 2014 +0000
- Parent:
- 2:b4e2eee99a28
- Commit message:
- use the GPIO to realize the led flowing
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b4e2eee99a28 -r 743f42c80067 main.cpp --- a/main.cpp Sat Sep 20 21:47:16 2014 +0000 +++ b/main.cpp Tue Oct 14 02:05:10 2014 +0000 @@ -1,12 +1,30 @@ +/********************************* +*file name:LED flow +*creator: Jacob Shi +*Time :2014/10/10 +*illustration : make the led1~ +*led3 flow + ********************************/ #include "mbed.h" - -DigitalOut myled(LED1); - -int main() { - while(1) { - myled = 1; // turn myled on - wait(0.2); - myled = 0; // turn myled off - wait(0.2); +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +int state=0; +int main(void) +{ + while(1) + { + switch(state) + { + case 0: led1=1;led2=0;led3=0;state++;break; + case 1: led1=0;led2=1;led3=0;state++;break; + case 2: led1=0;led2=0;led3=1;state++;break; + default: break; + } + if(state==3) + state=0; + wait(0.3); } } + +