Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:2786b9d7a210, 2015-05-28 (annotated)
- Committer:
- pedro_C
- Date:
- Thu May 28 22:56:19 2015 +0000
- Revision:
- 0:2786b9d7a210
- Child:
- 1:9a0e9ef94ac6
serial buffer array test1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pedro_C | 0:2786b9d7a210 | 1 | #include "mbed.h" |
| pedro_C | 0:2786b9d7a210 | 2 | |
| pedro_C | 0:2786b9d7a210 | 3 | |
| pedro_C | 0:2786b9d7a210 | 4 | |
| pedro_C | 0:2786b9d7a210 | 5 | Serial pc(USBTX, USBRX); // tx, rx |
| pedro_C | 0:2786b9d7a210 | 6 | |
| pedro_C | 0:2786b9d7a210 | 7 | int j=0; |
| pedro_C | 0:2786b9d7a210 | 8 | int x=0; |
| pedro_C | 0:2786b9d7a210 | 9 | |
| pedro_C | 0:2786b9d7a210 | 10 | |
| pedro_C | 0:2786b9d7a210 | 11 | char X_buffer []= {0,0}; |
| pedro_C | 0:2786b9d7a210 | 12 | |
| pedro_C | 0:2786b9d7a210 | 13 | |
| pedro_C | 0:2786b9d7a210 | 14 | |
| pedro_C | 0:2786b9d7a210 | 15 | void readSerialString () |
| pedro_C | 0:2786b9d7a210 | 16 | { |
| pedro_C | 0:2786b9d7a210 | 17 | j=0; |
| pedro_C | 0:2786b9d7a210 | 18 | while(j<=1) { |
| pedro_C | 0:2786b9d7a210 | 19 | X_buffer[j] = pc.getc(); |
| pedro_C | 0:2786b9d7a210 | 20 | //Serial.println(X_buffer[i]); |
| pedro_C | 0:2786b9d7a210 | 21 | j++; |
| pedro_C | 0:2786b9d7a210 | 22 | } |
| pedro_C | 0:2786b9d7a210 | 23 | |
| pedro_C | 0:2786b9d7a210 | 24 | } |
| pedro_C | 0:2786b9d7a210 | 25 | |
| pedro_C | 0:2786b9d7a210 | 26 | |
| pedro_C | 0:2786b9d7a210 | 27 | int main() |
| pedro_C | 0:2786b9d7a210 | 28 | |
| pedro_C | 0:2786b9d7a210 | 29 | { |
| pedro_C | 0:2786b9d7a210 | 30 | pc.baud(115200); |
| pedro_C | 0:2786b9d7a210 | 31 | |
| pedro_C | 0:2786b9d7a210 | 32 | while(1) { |
| pedro_C | 0:2786b9d7a210 | 33 | readSerialString (); |
| pedro_C | 0:2786b9d7a210 | 34 | |
| pedro_C | 0:2786b9d7a210 | 35 | |
| pedro_C | 0:2786b9d7a210 | 36 | x=atoi(X_buffer); |
| pedro_C | 0:2786b9d7a210 | 37 | |
| pedro_C | 0:2786b9d7a210 | 38 | pc.printf("%d\n",x); |
| pedro_C | 0:2786b9d7a210 | 39 | |
| pedro_C | 0:2786b9d7a210 | 40 | } |
| pedro_C | 0:2786b9d7a210 | 41 | } |