Simple example of reading a single character and a series of characters in to a buffer from a serial port

Dependencies:   mbed

main.cpp

Committer:
simon
Date:
2012-06-10
Revision:
0:dc609501b657

File content as of revision 0:dc609501b657:

#include "mbed.h"

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);

int main() {
    char c;
    char buffer[128];
    
    c = pc.getc();
    
    pc.gets(buffer, 4);

    pc.printf("I got '%c' and '%s'\n", c, buffer);    
}