This is my code for my temperature sensor. I want it to measure the air temperature, along with the max and min temperature readings. In my code, it can measure temperature, and keep the max temperature, but it can't keep the minimum temperature (it keeps displaying 0 degrees celsius for minimum temperature). Can someone please look at the code and help me out. I tried putting in other values for "float mini = " but it still didn't work out to give me the minimum temperature.
#define pin A0 // analog pin
float tempc = 0; // temperature variables
float val1;
float maxi = 0; // for max temperature
float mini = 0; //for min temperature
delay(1000);
if(tempc > maxi)
{
maxi = tempc;
} // set max temperature
if(mini < maxi)
{
mini = tempc;
} // set min temperature
Serial.print("?f"); // clear the LCD
delay(1000); // wait to give the display time to clear
Serial.print("?x00?y0"); // write message on display line 0
Sorry, i was trying different things, and i forgot to change it back to mini<tempc.
Thanks for your advice. How high a value should it be? i wanted the sensor to measure as low as 0 degrees, but if that is what's causing problems then i guess i should change it.
Otherwise set mini to a higher value than the sensor can return, maxi to a lower value than the sensor can return. -99999 and 99999 would be fairly good choices as seeing them immediate warns a human that something is wrong (ie no samples have been taken yet).