
ejemplo serial
Revision 0:e96c74fb13c2, committed 2019-10-07
- Comitter:
- sergio_restrepo
- Date:
- Mon Oct 07 23:30:09 2019 +0000
- Commit message:
- serial_ejemplo
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 07 23:30:09 2019 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +int i = 0; +char c; + +int main() { + pc.printf("Ingrese 1 para iniciar\nIngrese p para detener\n"); + c = pc.getc(); + while(1) { + if(c == '1'){ + pc.printf("%d\n",i); + i++; + wait(1); + if(pc.readable()){ + if (pc.getc()=='p'){ + return 0; + } + } + } + else{ + pc.printf("Error - Ingrese 1 para iniciar\n"); + c = pc.getc(); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 07 23:30:09 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file