       if(wpb.pressed() || secondsLeft == 0)
       {
         digitalWrite(MOTOR_PIN, LOW);
-        changedUIString = false;              // UI string will be changed back!
+        changedUIString = false;                        // UI string will be changed back!
         mode = Mode::SETTING_TIME;
-      }
+      } // if(wpb.pressed() || secondsLeft == 0)
       break;
-    }
-  }
-}
-
-inline void lcdPrintFormattedSecs(unsigned long seconds) //*** inline = suggestion to the compiler to paste the raw code of this function wherever it's called == performance optimization, no hopping pointers to callers and callbacks
+    } // case Mode::SPINNING
+  } // switch(mode)
+} // void loop()
+
+/* `inline` = suggestion to the compiler to paste the raw code of this function
+  wherever it's called == performance optimization, no hopping pointers to callers
+  and callbacks
+  */
+inline void lcdPrintFormattedSecs(unsigned long seconds)
 {
   lcd.print(seconds/60); lcd.print(F(":")); lcd.print((seconds%60 < 10 ? F("0") : F(""))); lcd.print(seconds%60);
 }

Compiled and Edited by: Albert Ju, Fu Yang Chin
*/

#include <LiquidCrystal.h>               // include the library code for display
                                         // because it's a file inside of the Arduino.app 's library folder, use <> DIRECTIVE
#include "LEDButton.h"                   // include custom library local to the .ino--within the same sketch folder
                                         // because it's a relative path in the same directory, use "" LITERAL PATHNAME

//---GLOBAL VARIABLES--//
//:: ***these variables MUST be global because they're being used by multiple totally separate functions--static local won't do
LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 6);   // initialize the library with the numbers of the interface pins

// White Pushbutton
const uint8_t WPB_IN_PIN = 2, WPB_LED_PIN = 13;
const unsigned int WPB_DEBOUNCE_DELAY = 500;
LEDButton wpb = LEDButton(WPB_IN_PIN, WPB_LED_PIN, WPB_DEBOUNCE_DELAY);

// PWM (Pulse-Width Modulation) Motor Control and Potentiometer
const uint8_t MOTOR_PIN = 9;
const uint8_t POT_PIN = A5;


//:: ***No magic numbers! Using case statements, enum will provide readable, self-documenting code for when switching modes
enum class Mode
{
  SETTING_TIME,
  SETTING_SPEED,
  SPINNING
};
Mode mode = Mode::SETTING_TIME;                       //*** initialization over assignment; set SETTING_TIME to be the first mode!

//---Function prototypes---//
inline void lcdPrintFormattedSecs(unsigned long seconds);

void setup()
{
  const uint8_t LCD_COLUMNS = 20, LCD_ROWS = 4;

  wpb.begin();
  wpb.turnLEDOn();                //

  pinMode(MOTOR_PIN, OUTPUT);
  pinMode(POT_PIN, INPUT);

  lcd.begin(LCD_COLUMNS, LCD_ROWS);
  lcd.setCursor(0, 0);
  lcd.print(F("  Dremel Centrifuge"));                //*** Serial or derived functions will store their String arguments in RAM, which is wasteful; F() stores them in flash memory, where the sketch is stored (largest storage)
  lcd.setCursor(0, 2);
  lcd.print(F("Set speed:"));
  lcd.setCursor(0, 3);
  lcd.print(F("   Push to Start!"));

  Serial.begin(9600);
}

void loop()
{
  /* Explanation of static keyword in C++:
   3 types of things can be static: (local) function variables, & class
   member data (variables and functions--functions = pointer to address of
   instructions). But `static` gets implemented the same way in each. There
   exists special memory segments called DATA and BSS (which is just DATA but
   for uninitialized data). At compile, global and `static` data are each *given
   their own addresses within DATA or BSS, addresses where they will live (be
   stored at) forever.* *When the program first runs, BEFORE main(), global and
   `static` data are initialized to whatever value you set in source code*--you
   can see this in the Assembly code. If you only declared global or `static`
   data, then they will be initialized to 0 and placed in BSS. `static` data is
   not deallocated when out of scope--*its address is permanent, and though the
   values that live there may change, those values will never be erased (as long
   as the program is running).* Of course, that `static` data can only be
   accessed when it's within scope, making it much safer than similar global data.
  */

                                                      //*** perform operations with data of the same type, so as to boost performance by not needing to implicitly typecast
  static unsigned long setDuration;                   // the duration that the centrifuge should run
  static unsigned long spinningStartTime;             // point on the timeline where the countdown starts, i.e. when wpb is pressed the second time
  static uint8_t motorSpeed;

  switch(mode)
  {
    case Mode::SETTING_TIME:
    {
      static bool changedUIString = false;            //*** because changedUIString is static, its state will always persist
      if(!changedUIString)
      {
        lcd.setCursor(0, 1);
        lcd.print(F("Set time: <"));
        changedUIString = true;                       //*** this block becomes unreachable after this, because this true value is remembered; therefore only done once when case first entered
      }

      setDuration = map(analogRead(POT_PIN), 0, 1024, 0, 901);

      lcd.setCursor(11, 1);
      lcdPrintFormattedSecs(setDuration);

      static bool changedUIString = false;
      if(!changedUIString)
      {
        analogWrite(MOTOR_PIN, motorSpeed);             // set motorSpeed once and you're done--the voltage stays there!

        lcd.setCursor(0, 1);
        lcd.print(F("Finished in: "));
        changedUIString = true;
        Serial.println("reached only once");
      } // if(!changedIUIString)

      unsigned long secondsLeft =                       // save RAM by only doing this calculation only once per loop()::SPINNING
      (setDuration - (millis() - spinningStartTime))/1000;

      lcd.setCursor(13, 1);
      lcdPrintFormattedSecs(secondsLeft);
