TaChing Yu
/
Serial_2
Revision 0:5d2615cbb0df, committed 2016-08-27
- Comitter:
- yu10078999
- Date:
- Sat Aug 27 11:22:23 2016 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Aug 27 11:22:23 2016 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +DigitalOut led(D2); +Serial pc(USBTX, USBRX); +char val; +int main() { + pc.baud(9600); + while(1) { + if(pc.readable()) { + pc.printf("Ready\n"); + val = pc.getc(); + if(val=='a'){ + led = 1 ; + pc.printf("LED ON\n"); + } + else if (val == 'b') { + led = 0; + pc.printf("LED OFF\n"); + } + } +} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Aug 27 11:22:23 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b0220dba8be7 \ No newline at end of file