Created
August 24, 2012 06:03
-
-
Save donghee/3446262 to your computer and use it in GitHub Desktop.
mbed Serialport read and write
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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