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.
Dependencies: mbed
main.cpp@1:03cb3b25065c, 2020-12-09 (annotated)
- Committer:
- KINU
- Date:
- Wed Dec 09 14:37:41 2020 +0000
- Revision:
- 1:03cb3b25065c
- Parent:
- 0:303ad425d2ac
ss
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryouheitakamoto | 0:303ad425d2ac | 1 | #include "mbed.h" |
KINU | 1:03cb3b25065c | 2 | #include "stdio.h" |
KINU | 1:03cb3b25065c | 3 | #include "stdlib.h" |
KINU | 1:03cb3b25065c | 4 | #include "time.h" |
KINU | 1:03cb3b25065c | 5 | |
ryouheitakamoto | 0:303ad425d2ac | 6 | |
KINU | 1:03cb3b25065c | 7 | Serial pc(SERIAL_TX, SERIAL_RX); |
KINU | 1:03cb3b25065c | 8 | Serial device(PA_9,PA_10); |
KINU | 1:03cb3b25065c | 9 | //Serial dir(PA_10); |
KINU | 1:03cb3b25065c | 10 | int main(){ |
KINU | 1:03cb3b25065c | 11 | |
KINU | 1:03cb3b25065c | 12 | char c; |
KINU | 1:03cb3b25065c | 13 | //clock_t start = clock(); |
KINU | 1:03cb3b25065c | 14 | |
KINU | 1:03cb3b25065c | 15 | while(9600) { |
KINU | 1:03cb3b25065c | 16 | c = device.getc(); |
KINU | 1:03cb3b25065c | 17 | if(c - '0') |
ryouheitakamoto | 0:303ad425d2ac | 18 | { |
ryouheitakamoto | 0:303ad425d2ac | 19 | pc.printf("1\r\n"); |
ryouheitakamoto | 0:303ad425d2ac | 20 | } |
ryouheitakamoto | 0:303ad425d2ac | 21 | else |
ryouheitakamoto | 0:303ad425d2ac | 22 | { |
ryouheitakamoto | 0:303ad425d2ac | 23 | pc.printf("0\r\n"); |
ryouheitakamoto | 0:303ad425d2ac | 24 | } |
KINU | 1:03cb3b25065c | 25 | } |
KINU | 1:03cb3b25065c | 26 | /* |
KINU | 1:03cb3b25065c | 27 | clock_t end = clock(); |
KINU | 1:03cb3b25065c | 28 | const double time = static_cast<double>(end-start) / CLOCKS_PER_SEC; |
KINU | 1:03cb3b25065c | 29 | printf("time %lf[s]\n",time); |
KINU | 1:03cb3b25065c | 30 | */ |
KINU | 1:03cb3b25065c | 31 | return 0; |
ryouheitakamoto | 0:303ad425d2ac | 32 | |
ryouheitakamoto | 0:303ad425d2ac | 33 | } |