TaChing Yu
/
Serial_2
Diff: main.cpp
- Revision:
- 0:5d2615cbb0df
--- /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