   }
 }
 
-void updateTitle() {
-  strTitle = strTitle.charAt(strTitle.length() - 1) + strTitle.substring(0, strTitle.length() - 1);
-  
-  mySerial.write(22);                   // no cursor
-  mySerial.write(12);                   // clear
-  mySerial.println(strTitle);           // first line, display title
-  mySerial.write(148);                  // new line
-  
-  int spaceCount = 16 - strTime.length() - 2;
-  String strSpace = "";
-  for (int i = 0; i < spaceCount; i++) {
-    strSpace += " ";
-  }
-  
-  strLine2 = strTime + strSpace + "PK";
-  
-  mySerial.print(strLine2);      // second line, display time and initials
-  Serial.println("Time: " + strTime);   // console debug
+// move the cursor to a specific place
+// e.g.: cursorSet(3,2) sets the cursor to x = 3 and y = 2
+void cursorSet(int xpos, int ypos){  
+  Serial.write(254);
+  Serial.write(71);               
+  Serial.write(xpos);   //Column position   
+  Serial.write(ypos); //Row position 
+} 
+
+void updateLCD() {
+  // scroll left to right
+  strTitleDisplay = strTitleDisplay.charAt(strTitleDisplay.length() - 1) + strTitleDisplay.substring(0, strTitleDisplay.length() - 1);
+  
+  if (bTimerDone) {
+    strGradDisplay = strGradDisplay.charAt(strGradDisplay.length() - 1) + strGradDisplay.substring(0, strGradDisplay.length() - 1);
+  }
+  
+  // first line, display title
+  if (bTimerDone) {
+     mySerial.print(strGradDisplay);       // first line, display congrats
+     mySerial.write(148);                  // new line
+     
+     int spaceCount = 16 - strTime.length() - 2;
+     String strSpace = "";
+     for (int i = 0; i < spaceCount; i++) {
+       strSpace += " ";
+     }     
+     
+     // format DD:HH:MM:SS
+     String strD = printDigits(0, true);
+     String strH = printDigits(0, true);
+     String strM = printDigits(0, true);
+     String strS = printDigits(0, false);
+     strTime = strD+strH+strM+strS;
+     
+     // second line, display time and initials
+     strLine2 = strTime + strSpace + "PK";
+     mySerial.print(strLine2);
+     Serial.println("Time: " + strTime);   // console debug
+  } else {
+     mySerial.println(strTitleDisplay);
+     int spaceCount = 16 - strTime.length() - 2;
+     String strSpace = "";
+     for (int i = 0; i < spaceCount; i++) {
+       strSpace += " ";
+     }
+     
+     // second line, display time and initials
+     strLine2 = strTime + strSpace + "PK";
+     mySerial.print(strLine2);
+     Serial.println("Time: " + strTime);   // console debug
+  }
 }
 
 // Get time left in DD:HH:MM:SS format.

#include <SimpleTimer.h>

//--- SETTINGS ---
String strTitle = " 2016 GRADUATION";         // title - must be 16 characters, add padding to front
const String strGrad = "CONGRATS GRADS!";     // timer done message - max 16 characters
const int lcdPin = 2;                         // pin for LCD

// time to count down from

SimpleTimer myTimer;
int timerId, timerId2, timerId3;                          // reference to clock timer, light timer, and title timer
String strTime, strLine2;
String strTitleDisplay = strTitle;
String strGradDisplay = strGrad;
boolean bTimerDone = false;

// Configure display and timer.
void setup() {
  pinMode(lcdPin, OUTPUT);                                // set lcdPin as output to LCD
  pinMode(onBoardLEDPin, OUTPUT);                         // set onBoardLEDPin as output to LCD
  mySerial.begin(9600);                                   // start serial
  mySerial.write(22);                                     // no cursor
  timerId = myTimer.setInterval(1000, updateClock);       // update clock time every 1 sec
  timerId2 = myTimer.setInterval(500, flashLED);          // flash light every 0.5 sec
  timerId3 = myTimer.setInterval(350, updateLCD);         // update lcd every 0.35 sec
  setupTime();                                            // setup time left
  delay(100);
  
  // pad title string with 16 whitespaces in the front
  int padding = strTitle.length() % 16;
  
  // scroll left to right
  for (int i = 0; i < padding; i++) {
     strTitleDisplay = " " + strTitleDisplay;
  }
  
  // pad title string with 16 whitespaces in the front
  padding = strGrad.length() % 16;
  
  // scroll left to right
  for (int i = 0; i < padding; i++) {
     strGradDisplay = " " + strGradDisplay;
  }
}

