La primera publicación

Dependencies:   mbed

Committer:
sagilar
Date:
Sat Mar 14 01:25:43 2015 +0000
Revision:
1:068629f1b91f
Parent:
0:d116054f9d67
First Program Using Mbed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sagilar 0:d116054f9d67 1 #include "mbed.h"
sagilar 1:068629f1b91f 2 Serial pc(USBTX, USBRX); // tx, rx
sagilar 0:d116054f9d67 3 DigitalOut myled(LED1);
sagilar 1:068629f1b91f 4 DigitalOut myledg(LED2);
sagilar 1:068629f1b91f 5 DigitalOut myledb(LED3);
sagilar 1:068629f1b91f 6 int k = 0;
sagilar 1:068629f1b91f 7 int a;
sagilar 0:d116054f9d67 8 int main() {
sagilar 1:068629f1b91f 9 myled = 1;
sagilar 1:068629f1b91f 10 myledg = 1;
sagilar 1:068629f1b91f 11 myledb = 1;
sagilar 1:068629f1b91f 12 pc.printf("Que led desea encender? \n");
sagilar 1:068629f1b91f 13 pc.printf("1 : Rojo \n");
sagilar 1:068629f1b91f 14 pc.printf("2 : Verde \n");
sagilar 1:068629f1b91f 15 pc.printf("3 : Azul \n");
sagilar 0:d116054f9d67 16 while(1) {
sagilar 1:068629f1b91f 17 a=pc.getc();
sagilar 1:068629f1b91f 18 if (a==49){
sagilar 1:068629f1b91f 19 myled = !myled;
sagilar 1:068629f1b91f 20 pc.printf("Ok! \n");
sagilar 1:068629f1b91f 21 }
sagilar 1:068629f1b91f 22 if (a==50){
sagilar 1:068629f1b91f 23 myledg = !myledg;
sagilar 1:068629f1b91f 24 pc.printf("Ok! \n");
sagilar 1:068629f1b91f 25 }
sagilar 1:068629f1b91f 26 if (a==51){
sagilar 1:068629f1b91f 27 myledb = !myledb;
sagilar 1:068629f1b91f 28 pc.printf("Ok! \n");
sagilar 1:068629f1b91f 29 }
sagilar 0:d116054f9d67 30 }
sagilar 0:d116054f9d67 31 }