![](/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:
- 2020-01-22
- Revision:
- 4:a2d1329d042c
- Parent:
- 3:5b27b27e68ab
File content as of revision 4:a2d1329d042c:
// Serial demo using mbed 5 #include "mbed.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(c); // echo twice pc.putc('\r'); pc.putc('\n'); wait(0.5); pc.printf("Enter a character>"); } }