     }
   }
   else { // Uesd to debug a bmp file
+    if (digitalRead(TEST_PIN) != pastTest) {
+      displaySplashScreen(Test);
+      fileNumber = 1;
+      pastTest = digitalRead(TEST_PIN);
+    }
     if (bmpDraw(TESTPICTURE, 0, 0)) delay(DELAY_TIME);
   }
 }


  if (digitalRead(TEST_PIN) == LOW) {  // Used for debugging
    // Check if the mode switch has changed
    if (digitalRead(MODE_PIN) != pastMode) {
      Serial.print("Mode = ");
      Serial.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
      Serial.println();
      // Display splash screen
      displaySplashScreen();
      pastMode = digitalRead(MODE_PIN);
    }
    // Check fo mode
    if (digitalRead(MODE_PIN) == HIGH) {

    Serial.println('1');
  }
  else {
    Serial.println(numberOfFiles);
  }

  tft.setRotation(0); // Portrait

  // Seed random number generator
  randomSeed(analogRead(A0));

  // Display splash screen
  if (digitalRead(TEST_PIN) == LOW) {
    Serial.print("Mode = ");
    Serial.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
    Serial.println();
    displaySplashScreen();
  }
  else {
    Serial.print("Mode = ");
    Serial.println("TEST");
    Serial.println();
    displaySplashScreen(Test);
  }
  pastMode = digitalRead(MODE_PIN);
}

// The loop (runs forever)
