       startModeMillis = millis();
       lastReadingMillis = startModeMillis;
       mode = TEMPERATURE;
+    } else {
+      // Just turned off:
+      turnOffAllLedPins();
     }
   }
   previousMercurySwitchIsOn = mercurySwitchIsOn;
-  
+
   // Read data from sensor
   errorCode = readData();
   if (errorCode < 0) {

    SEGMENT_ON = HIGH;
  }
  
  analogWrite(DIGIT_1_PIN, DIGIT_OFF);
  analogWrite(DIGIT_2_PIN, DIGIT_OFF);
  analogWrite(DIGIT_3_PIN, DIGIT_OFF);
  analogWrite(DIGIT_4_PIN, DIGIT_OFF);
  digitalWrite(SEGMENT_A_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_B_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_C_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_D_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_E_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_F_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_G_PIN, SEGMENT_ON);
  digitalWrite(SEGMENT_DP_PIN, SEGMENT_ON);
  
  if (AUTO_START) {
    previousMercurySwitchIsOn = false;

      digitalWrite(SEGMENT_G_PIN, SEGMENT_OFF);
  }
  digitalWrite(SEGMENT_DP_PIN, hasDecimalPoint ? SEGMENT_ON : SEGMENT_OFF);
}

void turnOffAllLedPins() {
  analogWrite(DIGIT_1_PIN, LOW);
  analogWrite(DIGIT_2_PIN, LOW);
  analogWrite(DIGIT_3_PIN, LOW);
  analogWrite(DIGIT_4_PIN, LOW);
  digitalWrite(SEGMENT_A_PIN, LOW);
  digitalWrite(SEGMENT_B_PIN, LOW);
  digitalWrite(SEGMENT_C_PIN, LOW);
  digitalWrite(SEGMENT_D_PIN, LOW);
  digitalWrite(SEGMENT_E_PIN, LOW);
  digitalWrite(SEGMENT_F_PIN, LOW);
  digitalWrite(SEGMENT_G_PIN, LOW);
  digitalWrite(SEGMENT_DP_PIN, LOW);
}

int readData() {
