Benny Gómez
/
Serial_Shit_SLAVE
jajajaja
main.cpp@0:1bdfe2ebaecd, 2017-06-03 (annotated)
- Committer:
- sick010203
- Date:
- Sat Jun 03 17:50:51 2017 +0000
- Revision:
- 0:1bdfe2ebaecd
Esclavo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sick010203 | 0:1bdfe2ebaecd | 1 | #include "mbed.h" |
sick010203 | 0:1bdfe2ebaecd | 2 | #include "SoftSerial.h" |
sick010203 | 0:1bdfe2ebaecd | 3 | #include <string> |
sick010203 | 0:1bdfe2ebaecd | 4 | SoftSerial micro(D2,D3); |
sick010203 | 0:1bdfe2ebaecd | 5 | Serial pc (USBTX, USBRX); |
sick010203 | 0:1bdfe2ebaecd | 6 | DigitalOut bad(LED2); |
sick010203 | 0:1bdfe2ebaecd | 7 | |
sick010203 | 0:1bdfe2ebaecd | 8 | |
sick010203 | 0:1bdfe2ebaecd | 9 | int main () { |
sick010203 | 0:1bdfe2ebaecd | 10 | micro.baud(9600); |
sick010203 | 0:1bdfe2ebaecd | 11 | pc.baud(9600); |
sick010203 | 0:1bdfe2ebaecd | 12 | |
sick010203 | 0:1bdfe2ebaecd | 13 | string readString; |
sick010203 | 0:1bdfe2ebaecd | 14 | char message [125]; |
sick010203 | 0:1bdfe2ebaecd | 15 | |
sick010203 | 0:1bdfe2ebaecd | 16 | while (1) |
sick010203 | 0:1bdfe2ebaecd | 17 | { |
sick010203 | 0:1bdfe2ebaecd | 18 | while (micro.readable()>0) |
sick010203 | 0:1bdfe2ebaecd | 19 | { |
sick010203 | 0:1bdfe2ebaecd | 20 | wait(0.003); |
sick010203 | 0:1bdfe2ebaecd | 21 | //micro.gets(message,5); |
sick010203 | 0:1bdfe2ebaecd | 22 | micro.scanf("%s", message); |
sick010203 | 0:1bdfe2ebaecd | 23 | pc.printf("%s\r\n",message); |
sick010203 | 0:1bdfe2ebaecd | 24 | // readString += message; |
sick010203 | 0:1bdfe2ebaecd | 25 | //if (readString.length()>0) |
sick010203 | 0:1bdfe2ebaecd | 26 | //{ |
sick010203 | 0:1bdfe2ebaecd | 27 | // pc.printf("%s\r\n",readString); |
sick010203 | 0:1bdfe2ebaecd | 28 | //} |
sick010203 | 0:1bdfe2ebaecd | 29 | |
sick010203 | 0:1bdfe2ebaecd | 30 | readString=""; |
sick010203 | 0:1bdfe2ebaecd | 31 | break; |
sick010203 | 0:1bdfe2ebaecd | 32 | } |
sick010203 | 0:1bdfe2ebaecd | 33 | |
sick010203 | 0:1bdfe2ebaecd | 34 | } |
sick010203 | 0:1bdfe2ebaecd | 35 | |
sick010203 | 0:1bdfe2ebaecd | 36 | } |