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

  pinMode(SEGMENT_F_PIN, OUTPUT);
  pinMode(SEGMENT_G_PIN, OUTPUT);
  pinMode(SEGMENT_DP_PIN, OUTPUT);
  
  if (COMMON_ANODE_LED) {
    // LED display with common anode:
    DIGIT_OFF = 0;

    if (mode == TEMPERATURE) setTemperature();
    else setHumidity();
  }
 
  // Draw one current digit on display
  if (mercurySwitchIsOn) {
    activateDigit(INACTIVE);
    drawDigit(digits[currentDigitIndex], decimalPoints[currentDigitIndex]);
    if (mercurySwitchIsOn) {
      activateDigit(currentDigitIndex);
    }
  
    // Change current digit
    currentDigitIndex++;
    if (currentDigitIndex >= 4) currentDigitIndex = 0;
  }
  
  delayMicroseconds(DIGIT_DELAY_IN_MICROSECONDS);
}
