Used to create a USB -> Serial link between a PC and a serial device
Connect your serial device to p28 (tx) and p27 (rx). Change the baud rate to match your device. The baud rate must be the same for Serial pc and Serial device.
Diff: main.cpp
- Revision:
- 0:8e51213bffbc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 18 08:37:54 2014 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +DigitalOut myled(LED1); + +Serial pc(USBTX, USBRX); // tx, rx +Serial device(p28, p27); // tx, rx + +int main() { + + device.baud(115200); + pc.baud(115200); + + + while(1) { + if(pc.readable()) { + device.putc(pc.getc()); + } + if(device.readable()) { + myled = !myled; + pc.putc(device.getc()); + } + } +} \ No newline at end of file