shibata 芝田
/
mbed_blinky
シリアル通信成功サンプル
Diff: main.cpp
- Revision:
- 0:1fce8daac823
- Child:
- 1:7732cf688029
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Mar 14 12:34:03 2015 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +Serial pc(USBTX, USBRX); + +void callback() { + // Note: you need to actually read from the serial to clear the RX interrupt + printf("%c\n", pc.getc()); + led2 = !led2; +} + +int main() { + pc.attach(&callback); + + while (1) { + led1 = !led1; + wait(0.5); + } +} \ No newline at end of file