Show the max and min value

Hi , i made a simple thermometer using LM35 and LCD to show the temp but i want to show the min and max temp also and i don't have an idea can you help me ? here is the code

#include <LiquidCrystal.h>
LiquidCrystal lcd(11,10,7,6,5,4);
float tempC; 
int tempPin = 0;
int redledPin = 13;
int greenledPin = 12;

void setup() {
Serial.begin(9600);
pinMode(tempPin, INPUT);
pinMode(redledPin, OUTPUT); 
pinMode(greenledPin, OUTPUT); 
lcd.begin(16,2);
}
void loop() {
tempC = analogRead(tempPin); 
tempC = (5.0*tempC*100.00)/1024; 
lcd.setCursor(5,0);
lcd.print("TEMPERATURE");
lcd.setCursor(6,1);
lcd.print(tempC);
if(tempC>25)
 {
  digitalWrite(redledPin, HIGH);
  digitalWrite(greenledPin, LOW); 
  }
if(tempC<25)
 {
  digitalWrite(redledPin, LOW);
  digitalWrite(greenledPin, HIGH);
 }
delay(3000);
}

and i don't have an idea

You must have SOME idea. After all, it isn't rocket science to determine if this value is more than that value. If it is, that value isn't the max. This value is.

It isn't rocket science to determine if this value is less than that value. If it is, that value isn't the min. This one is.

PaulS:
You must have SOME idea. After all, it isn't rocket science to determine if this value is more than that value. If it is, that value isn't the max. This value is.

It isn't rocket science to determine if this value is less than that value. If it is, that value isn't the min. This one is.

Thanks for you reply i tried to did what you said the max value works fine but the min value keep showing 0 only the lm35 reading is between 20 and 30 here is what i did

int tempC ;
int maxtemp ;
int mintemp ;
if (tempC > maxtemp) maxtemp = tempC ;
if (tempC < mintemp) mintemp = tempC ;

If you declared minTemp and maxTemp as global variables, then they got initialized to 0. So, no temp was lower than that, so the code correctly pointed that out.

Give minTemp and maxTemp unreasonable initial values.

int minTemp = 32000;
int maxTemp = -32000;

Hi,
try;

int maxtemp = 0 ;
int mintemp = 100;

It sounds like you are starting with mintemp already at 0.

Starting at 100, it will be instantly changed on the first time your code does the if.

Tom... :slight_smile:
EDIT (Damn missed it by that much.. lol)

It works

Thank you so much for the help