Skip to content

Instantly share code, notes, and snippets.

@donghee
Created August 24, 2012 06:03
Show Gist options
  • Save donghee/3446262 to your computer and use it in GitHub Desktop.
Save donghee/3446262 to your computer and use it in GitHub Desktop.
mbed Serialport read and write
#include "mbed.h"
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
char serialValue;
int main() {
while(1) {
if(pc.readable()) {
serialValue = pc.getc();
pc.putc(serialValue);
if (serialValue == '1') {
myled = 1;
}
else {
myled = 0;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment