ejemplo serial

Dependencies:   mbed

main.cpp

Committer:
sergio_restrepo
Date:
2019-10-07
Revision:
0:e96c74fb13c2

File content as of revision 0:e96c74fb13c2:

#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();
        }
    }
}