Why Are My High and Low Values Not Updating Correctly During Successive Loops I am attempting to capture the high and low temperature and humidity values, then clearing the LCD and displaying them on 2 successive screen updates. All is working correctly except that the variables for high and low are updating on every loop to the current sensor pin read after the &quot;if&quot; statements are run. Why is this occurring?
Also note that I declare the floats for the highs and lows to the unlikely value of 10000 in order to change them all to the initial pin read on the 1st loop as I didn't find a method to determine null on the initial loop.  I would appreciate any suggestions for a better method!  TIA
    #include &lt;dht.h&gt;
    #include &lt;LiquidCrystal.h&gt;

    //Low and High Temp and Humidity Variables
    float lTemp=10000;
    float hTemp=10000;
    float lHumid=10000;
    float hHumid=10000;

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    dht DHT;

    #define DHT11_PIN 7

    void setup(){
      lcd.begin(16, 2);
      Serial.begin(9600);
    }


    void loop(){
       lcd.clear();

      int chk = DHT.read11(DHT11_PIN);

      float CurrTemp = DHT.temperature * 1.8 + 32;  //Converts celsius read from DHT read to farenheit

    //Sets High and Low Temperature Readings

       if (lTemp = 10000) {
         lTemp = CurrTemp;
       }
      if (CurrTemp &lt; lTemp) {
         lTemp = CurrTemp;
      }

      if (hTemp = 10000) {
        hTemp= CurrTemp;
      }
       if (CurrTemp &gt; hTemp) {
        hTemp = CurrTemp;
      }

    //Sets High and Low Humidity Readings

      if (lHumid = 10000) {
        lHumid = DHT.humidity;
       }
      if (DHT.humidity &lt; lHumid) {
        lHumid = DHT.humidity;
      }

      if (hHumid = 10000) {
        hHumid = DHT.humidity;
      }
      if (DHT.humidity &gt; hHumid) {
        hHumid = DHT.humidity;
      }

      //Prints Current Temp and Humidity to LCD and Serial Monitor
      lcd.setCursor(0,0); 
      lcd.print(&quot;Temp: &quot;);
      lcd.print(CurrTemp,1);
      lcd.print((char)223);
      lcd.print(&quot;F&quot;);

      Serial.print(CurrTemp,1);

      Serial.println(&quot; F&quot;);

      lcd.setCursor(0,1);

      lcd.print(&quot;Humidity: &quot;);
      lcd.print(DHT.humidity,0);
      lcd.print(&quot;%&quot;);

      Serial.print(&quot;Humidity: &quot;);
      Serial.print(DHT.humidity,0);
      Serial.println(&quot;%&quot;);
      Serial.println(&quot;&quot;);

      delay(10000);

      //Prints Low and High Temp to LCD and Serial Monitor
      lcd.clear();

      lcd.setCursor(0,0); 
      lcd.print(&quot;L Temp: &quot;);
      lcd.print(lTemp,1);
      lcd.print((char)223);
      lcd.print(&quot;F&quot;);

      Serial.print(&quot;Low Temp: &quot;);
      Serial.print(lTemp,1);
      //Serial.print((char,223);
      Serial.println(&quot; F&quot;);

      lcd.setCursor(0,1);

      lcd.print(&quot;H Temp: &quot;);
      lcd.print(hTemp,1);
      lcd.print((char)223);
      lcd.print(&quot;F&quot;);

      Serial.print(&quot;High Temp: &quot;);
      Serial.print(hTemp,1);
      Serial.println(&quot; F&quot;);
      Serial.println(&quot;&quot;);

      delay(3000);

     //Prints Low and High Humidity to LCD and Serial Monitor
      lcd.clear();

      lcd.setCursor(0,0); 
      lcd.print(&quot;Low Humid: &quot;);
      lcd.print(lHumid,0);
      lcd.print(&quot;%&quot;);

      Serial.print(&quot;Low Humid: &quot;);
      Serial.print(lHumid,0);
      Serial.println(&quot;%&quot;);

      lcd.setCursor(0,1);

      lcd.print(&quot;High Humid: &quot;);
      lcd.print(hHumid,0);
      lcd.print(&quot;%&quot;);

      Serial.print(&quot;High Humid: &quot;);
      Serial.print(hHumid,0);
      Serial.println(&quot;%&quot;);
      Serial.println(&quot;&quot;);

      delay(3000);

    }
Although you already have two perfectly valid answers, I will share a
trick that completely sidesteps the problem. Instead of choosing a
particular number (here, 10,000) as a “magic” value that has a special
meaning, you can instead initialize the highs and lows in a way that
ensures they will be updated on the very first iteration:

make lTemp higher than any temperature you may ever read
make hTemp lower than any temperature you may ever read

For example:
float lTemp = +INFINITY;
float hTemp = -INFINITY;

and the same of course for the humidities. This way the first iteration
does not need special handling anymore, as it becomes a regular
iteration:
if (CurrTemp &lt; lTemp) lTemp = CurrTemp;
if (CurrTemp &gt; hTemp) hTemp = CurrTemp;

Note that the choice of ±∞ for the min and max of an empty set of
readings is not just a dirty hack. It is actually consistent with the
mathematical notion of infimum and supremum of the empty
set.