![](/media/cache/profiles/Headshot_Fall2023_Square.jpg.50x50_q85.jpg)
Initial published version.
Diff: main.cpp
- Revision:
- 110:8170476d91a6
- Parent:
- 109:744c6cb711bf
--- a/main.cpp Thu Sep 23 03:03:59 2021 +0000 +++ b/main.cpp Fri Sep 24 16:28:15 2021 +0000 @@ -16,12 +16,14 @@ // not good practice, but I want to use the DigitalIn object in these // contexts to illustrate my points. See while loop below for a better // (more common and realistic) approach. - while(true) { + //while(true) { // Standard infinite loop. + for (;;) { // Alternative infinite loop. // Use the button in some printf calls. printf("\nuB (w/o cast) = %d.\n", uB); // Bad! Warning! Wrong! printf("uB (with int cast) = %d.\n", static_cast<int>(uB)); // I found a reference that claimed there is a %b (or B) speicifer for - // type bool, but it doesn't work in mbed. + // type bool, but it doesn't work in mbed. So use %d to see it as a + // decimal value. printf("uB (with bool cast) = %d.\n", static_cast<bool>(uB)); printf("uB.read = %d.\n", uB.read()); @@ -62,6 +64,9 @@ } //end of if. ThisThread::sleep_for(500); // For 0.5 seconds in while. } // end of !uBstate while. - printf("End of main while.\n\n"); + if (uBstate) + printf("Button released during countdown.\n\n"); + else + printf("Countdown completed.\n\n"); } // end of main while. } // end of main function. \ No newline at end of file