    digitalWrite(latchPin, HIGH);
 }
 
+bool splitNumber(double n) {
+  //takes the input n and puts into the array num, split into 4 digits from lsb to msb
+  double fractional;
+  double integral;
+  int i;
+  bool negative = false;
+
+  int store[]={-1,-1,-1,-1};
+
+  //clear previous values of the num array
+  for (i=0; i<4; i++)
+    displayNum[i] = off;
+
+  if (n < 0.0) {
+    n = abs(n);
+    negative = true;
+  }
+
+  fractional = modf(n, &integral);
+  fractional = round(fractional*10);
+  int decimal = int(fractional);
+  int whole = int(integral);
+
+  if (decimal >= 10) {
+    decimal = 0;
+    whole++;
+  }
+
+  if (negative) {
+    if (whole >= 100)
+      return false;
+    displayNum[3] = minus;
+  }
+  else {
+    if (whole >= 1000)
+      return false;
+  }
+  
+  displayNum[0] = numbers[decimal];
+
+  // if whole is 0 to 9
+  if (whole < 10) {
+    store[1] = whole;
+  }
+  //else if whole is 10-99
+  else if (whole < 100) {
+    store[2] = whole / 10;
+    store[1] = whole % 10;
+  }
+  //else if whole is 100-999
+  else if (whole < 1000) {
+    store[3] = whole / 100;
+    whole = whole % 100;
+    store[2] = whole / 10;
+    store[1] = whole % 10;
+  }
+  
+  for (i=1; i<4; i++) {
+    if (store[i]!=-1)
+      displayNum[i] = numbers[store[i]];
+  }
+
+  displayNum[1]++;
+
+  return true;
+}
 
 //global variables for the test function
-const long testInterval = 500; //counter delay in milliseconds
+const long testInterval = 50; //counter delay in milliseconds
 
 long previousTestTime = 0; //previous count time
-double testLoop = 0; //counter for counting loop
+double testLoop = -100; //counter for counting loop
 
 void testCaseAllNum() {
   //test case, a loop timer that runs through each integer from 0 to 9999


byte displayNum[] = {off, off, off, off};  //array for display numbers from msb to lsb

bool negative = false;

const long refreshInterval = 10; //refresh delay in microseconds
long previousRefresh = 0; //previous refresh time
int refreshLoop = 0;  //counter for refreshing loop

void displayNumber() {
  //turn on the LEDs accoring to the number stored in array num on the refresh cycle
  updateShiftRegister(displayNum[refreshLoop]);
}

void updateShiftRegister(byte leds) {
