Santiago Gil
/
mbed_blinky
La primera publicación
Revision 1:068629f1b91f, committed 2015-03-14
- Comitter:
- sagilar
- Date:
- Sat Mar 14 01:25:43 2015 +0000
- Parent:
- 0:d116054f9d67
- Commit message:
- First Program Using Mbed
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Mar 13 16:00:06 2015 +0000 +++ b/main.cpp Sat Mar 14 01:25:43 2015 +0000 @@ -1,12 +1,31 @@ #include "mbed.h" - +Serial pc(USBTX, USBRX); // tx, rx DigitalOut myled(LED1); - +DigitalOut myledg(LED2); +DigitalOut myledb(LED3); +int k = 0; +int a; int main() { + myled = 1; +myledg = 1; +myledb = 1; +pc.printf("Que led desea encender? \n"); +pc.printf("1 : Rojo \n"); +pc.printf("2 : Verde \n"); +pc.printf("3 : Azul \n"); while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + a=pc.getc(); + if (a==49){ + myled = !myled; + pc.printf("Ok! \n"); + } + if (a==50){ + myledg = !myledg; + pc.printf("Ok! \n"); + } + if (a==51){ + myledb = !myledb; + pc.printf("Ok! \n"); + } } }