Simple example of a serial port communicating with another serial port

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // example showing sending/receiving character
00002 
00003 #include "mbed.h"
00004 
00005 // connect p9 to p14 with a wire!
00006 Serial out(p9, NC);
00007 Serial in(NC, p14);
00008 
00009 DigitalOut led(LED1);
00010 
00011 int main() {
00012     out.putc('h');
00013     out.putc('i');
00014     char c1 = in.getc();
00015     char c2 = in.getc();
00016     
00017     led = 1;
00018     printf("c1: %c, c2: %c\n", c1, c2); 
00019 }