CRISTIAN YOMAYUZA
/
Comunicaciondoble
comunicacion serial
main.cpp@0:6f4089757c91, 2017-09-28 (annotated)
- Committer:
- cristiany
- Date:
- Thu Sep 28 00:34:10 2017 +0000
- Revision:
- 0:6f4089757c91
Comunicacion doble;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cristiany | 0:6f4089757c91 | 1 | #include "mbed.h" |
cristiany | 0:6f4089757c91 | 2 | #include "SoftSerial.h" |
cristiany | 0:6f4089757c91 | 3 | |
cristiany | 0:6f4089757c91 | 4 | SoftSerial MB(D2,D3); |
cristiany | 0:6f4089757c91 | 5 | Serial PC(USBTX,USBRX); |
cristiany | 0:6f4089757c91 | 6 | char rec; |
cristiany | 0:6f4089757c91 | 7 | char send; |
cristiany | 0:6f4089757c91 | 8 | int main() |
cristiany | 0:6f4089757c91 | 9 | { |
cristiany | 0:6f4089757c91 | 10 | |
cristiany | 0:6f4089757c91 | 11 | while(1) |
cristiany | 0:6f4089757c91 | 12 | { |
cristiany | 0:6f4089757c91 | 13 | if(PC.readable()>0) |
cristiany | 0:6f4089757c91 | 14 | { |
cristiany | 0:6f4089757c91 | 15 | |
cristiany | 0:6f4089757c91 | 16 | send=PC.getc(); |
cristiany | 0:6f4089757c91 | 17 | MB.printf("%c",send); |
cristiany | 0:6f4089757c91 | 18 | PC.printf("%c",send) ; |
cristiany | 0:6f4089757c91 | 19 | wait(0.2); |
cristiany | 0:6f4089757c91 | 20 | } |
cristiany | 0:6f4089757c91 | 21 | if(MB.readable()> 0) |
cristiany | 0:6f4089757c91 | 22 | { |
cristiany | 0:6f4089757c91 | 23 | rec=MB.getc(); |
cristiany | 0:6f4089757c91 | 24 | PC.printf("%c",rec); |
cristiany | 0:6f4089757c91 | 25 | wait(0.2); |
cristiany | 0:6f4089757c91 | 26 | } |
cristiany | 0:6f4089757c91 | 27 | |
cristiany | 0:6f4089757c91 | 28 | } |
cristiany | 0:6f4089757c91 | 29 | } |