シリアル通信のテスト用
Dependencies: mbed
main.cpp@0:0eb43c144d1b, 2016-09-14 (annotated)
- Committer:
- nissin_2411
- Date:
- Wed Sep 14 15:38:51 2016 +0000
- Revision:
- 0:0eb43c144d1b
serial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nissin_2411 | 0:0eb43c144d1b | 1 | #include "mbed.h" |
nissin_2411 | 0:0eb43c144d1b | 2 | |
nissin_2411 | 0:0eb43c144d1b | 3 | Serial pc(USBTX, USBRX); // tx, rx |
nissin_2411 | 0:0eb43c144d1b | 4 | Serial serialPin(dp16,dp15); |
nissin_2411 | 0:0eb43c144d1b | 5 | |
nissin_2411 | 0:0eb43c144d1b | 6 | int main() { |
nissin_2411 | 0:0eb43c144d1b | 7 | pc.baud(9600); |
nissin_2411 | 0:0eb43c144d1b | 8 | serialPin.baud(9600); |
nissin_2411 | 0:0eb43c144d1b | 9 | pc.printf("Hello World!"); |
nissin_2411 | 0:0eb43c144d1b | 10 | int num; |
nissin_2411 | 0:0eb43c144d1b | 11 | while(1) { |
nissin_2411 | 0:0eb43c144d1b | 12 | num=serialPin.getc(); |
nissin_2411 | 0:0eb43c144d1b | 13 | pc.putc(num); |
nissin_2411 | 0:0eb43c144d1b | 14 | if(num==1){ |
nissin_2411 | 0:0eb43c144d1b | 15 | pc.printf("get1"); |
nissin_2411 | 0:0eb43c144d1b | 16 | } |
nissin_2411 | 0:0eb43c144d1b | 17 | if(num==0){ |
nissin_2411 | 0:0eb43c144d1b | 18 | pc.printf("get0"); |
nissin_2411 | 0:0eb43c144d1b | 19 | } |
nissin_2411 | 0:0eb43c144d1b | 20 | } |
nissin_2411 | 0:0eb43c144d1b | 21 | } |