Test program for serial interface

This program turns the red LED on and then waits for a character to be entered at the terminal. The LED then goes off for 500ms before the cycle repeats.

The purpose of the program is to demonstrate the use of the serial link

main.cpp

Committer:
WilliamMarshQMUL
Date:
2017-01-16
Revision:
0:75835b5692b9
Child:
1:961580c296da

File content as of revision 0:75835b5692b9:

#include "mbed.h"
#include "rtos.h"

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX); // tx, rx

int main() {
    char c ;
    pc.printf("Enter a character>");
    while(1) {
        myled = 0;  // turn on
        c = pc.getc();
        myled = 1;  // turn off
        pc.putc(c);
        pc.putc('\n');
        Thread::wait(500);
        pc.printf("Enter a character>");
    }
}