![](/media/cache/profiles/8631e5b91354a846f00dbbf16ad94259.jpg.50x50_q85.jpg)
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-25
- Revision:
- 1:961580c296da
- Parent:
- 0:75835b5692b9
- Child:
- 2:e92d97ac59e4
File content as of revision 1:961580c296da:
#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('\r'); pc.putc('\n'); Thread::wait(500); pc.printf("Enter a character>"); } }