
Use this project as a starting point for simple IO testing in Mbed. This is the initial version.
Revision 116:a08f67e4d8e1, committed 2021-10-21
- Comitter:
- CSTritt
- Date:
- Thu Oct 21 10:16:51 2021 +0000
- Parent:
- 115:f22cbbc92bae
- Commit message:
- Added explicit Serial port, pc.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 13 14:27:35 2021 +0000 +++ b/main.cpp Thu Oct 21 10:16:51 2021 +0000 @@ -12,22 +12,24 @@ */ #include "mbed.h" +Serial pc(USBTX, NC, 9600); + int main() { const int DELAY = 2000000;; // mS wait time. const char ESC = 27; // Define escape character for escape sequence. - printf("%c[2J%c[H", ESC, ESC); // ANSI/VT100 clear screen/home. + pc.printf("%c[2J%c[H", ESC, ESC); // ANSI/VT100 clear screen/home. // Replace the code below with your code. - int count = 1; // Declared in outer block. - int iCount = 0; // This is another variable called count. + int count = 1; // Do while loop counter. + int iCount = 0; // Counter in do-while loop. do { --iCount; // this applies to inner count. printf("Count Down = %d and abs(Count Down) = %d\n", iCount, abs(iCount)); } while( ++count <= 5); // This works with outer count. - printf("count = %d\n", count); // Inner count is dead. + pc.printf("count = %d\n", count); while(true) { // Main forever loop. ThisThread::sleep_for(DELAY); // Pause