예제7) 블루투스 모듈 이름 변경
Dependencies: mbed-src
Fork of HC-05_S2B_HelloWorld_WIZwiki-W7500 by
main.cpp@1:b976dec64b41, 2017-10-17 (annotated)
- Committer:
- robertchoi
- Date:
- Tue Oct 17 04:08:56 2017 +0000
- Revision:
- 1:b976dec64b41
- Parent:
- 0:a4c1f76c9564
??7) ???? ?? ?? ??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
justinkim | 0:a4c1f76c9564 | 1 | #include "mbed.h" |
justinkim | 0:a4c1f76c9564 | 2 | |
justinkim | 0:a4c1f76c9564 | 3 | Serial pc(USBTX, USBRX); |
robertchoi | 1:b976dec64b41 | 4 | Serial bt(D1, D0); |
justinkim | 0:a4c1f76c9564 | 5 | |
justinkim | 0:a4c1f76c9564 | 6 | int main(void) |
justinkim | 0:a4c1f76c9564 | 7 | { |
justinkim | 0:a4c1f76c9564 | 8 | char ch; |
robertchoi | 1:b976dec64b41 | 9 | pc.baud(9600); |
robertchoi | 1:b976dec64b41 | 10 | bt.baud(9600); |
robertchoi | 1:b976dec64b41 | 11 | pc.printf("Hello World! HC-06 bluetooth example...\n\r"); |
justinkim | 0:a4c1f76c9564 | 12 | |
justinkim | 0:a4c1f76c9564 | 13 | while(1) |
justinkim | 0:a4c1f76c9564 | 14 | { |
justinkim | 0:a4c1f76c9564 | 15 | if(bt.readable()) |
justinkim | 0:a4c1f76c9564 | 16 | { |
justinkim | 0:a4c1f76c9564 | 17 | ch=bt.getc(); |
justinkim | 0:a4c1f76c9564 | 18 | pc.printf("%c",ch); |
justinkim | 0:a4c1f76c9564 | 19 | } |
justinkim | 0:a4c1f76c9564 | 20 | |
justinkim | 0:a4c1f76c9564 | 21 | else if(pc.readable()) |
justinkim | 0:a4c1f76c9564 | 22 | { |
justinkim | 0:a4c1f76c9564 | 23 | ch=pc.getc(); |
justinkim | 0:a4c1f76c9564 | 24 | bt.printf("%c",ch); |
justinkim | 0:a4c1f76c9564 | 25 | } |
justinkim | 0:a4c1f76c9564 | 26 | } |
justinkim | 0:a4c1f76c9564 | 27 | } |