Sam Beh / Mbed 2 deprecated Serial_Echo

Dependencies:   mbed

main.cpp

Committer:
pnkpntr
Date:
2018-09-26
Revision:
0:e67b3d8994f1

File content as of revision 0:e67b3d8994f1:

#include "mbed.h"              
 
Serial pc(USBTX, USBRX);
DigitalOut    led (LED1);

char cmd[100];

int main() {
    //pc.baud(19200);
    pc.baud(921600);
    //pc.printf("Echoes back to the screen anything you type\n");
    while(1) {
        if (pc.readable()>0)
        {
            led = 1;
            pc.scanf("%s",cmd);
            //pc.putc(pc.getc());
            led = 0;
            pc.printf(cmd);
        }
        else
        {
            //led = !led;
            wait(0.2);
        }
    }
}