Make a serial bridge from a serial I/O device on mbed to the PC

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  // Make a serial bridge from a serial I/O device on mbed to the PC
00003 Serial pc(USBTX, USBRX); // tx, rx
00004 Serial device(p13, p14);  // tx, rx
00005  // Defaults to 9600 baud on each device - use .baud(baudrate) to change
00006 int main() {
00007     while(1) {
00008         if(pc.readable()) {
00009             device.putc(pc.getc());
00010         }
00011         if(device.readable()) {
00012             pc.putc(device.getc());
00013         }
00014     }
00015 }
00016