Need help..Can't read average value from analog from call function

Dear all… i program my temperature sensor using AD595…i should check 3 condition of temperature reading… lets say first between 80 deg - 100, second 100-500deg and the last one for other reading… in second condition i need to have about another 10 stage which is to execute job if second condition 100-500deg is true…every stage will check the if statement condition before go to another stage… if false it will go back to main code (or continue checking other condition)… i did try all my best to get it right but i still same… could someone tell me what wrong … i post my code to explain better …with this code i got another problem… i got 0 value at lcd from “temp”…

/*
  The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
 Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 8 Feb 2010
by Tom Igoe
 This example code is in the public domain.
 
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
 
// include the library code:
#include <LiquidCrystal.h>
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int Thermocouple = A0;
float temp = 0;
 
const int numReadings = 1;
 
int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
 
int inputPin = A0;
int case1=0;
 
void setup() {
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;   
 
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  pinMode(7,OUTPUT); // LED Caution - Orange
  pinMode(6,OUTPUT); // LED Hot - Red
  pinMode(0,OUTPUT);  // Buzzer
  pinMode(8,OUTPUT); // Relay
 //Serial.begin(9600); // if need to display at serial computer but TX/RX pin (Digital 0 & 1) will not work properly 
 
}
 
void loop() 
{ 
  digitalWrite(6,HIGH); // LED "Caution" - Orange 'OFF' 
  digitalWrite(7,HIGH); // LED "Hot" - Red 'ON'
  digitalWrite(0,LOW);   //Buzzer 'OFF'
  digitalWrite(8,LOW);  // Relay 'OFF'
    Read_ADC();
      // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);  // print on first left lcd and 1st line:
  lcd.print("Temp: ");
  lcd.print(temp);
// Serial.println(temp); // if need to display at serial computer
  lcd.setCursor(11, 0);
  lcd.print("   ");
  lcd.setCursor(14, 0);
  lcd.print((char)223);
  lcd.setCursor(15, 0);
  lcd.print("C");        
  delay(250);
       
  
    Read_ADC();
  if ((temp>85)&&(temp<100))
  {
    lcd.setCursor(0, 1);
    lcd.print("Caution          ");
    digitalWrite(6,LOW); // LED "Caution" - Orange 'ON'
   delay(200);
    digitalWrite(6,HIGH); // LED "Caution" - Orange 'OFF'
    digitalWrite(0,HIGH); //Buzzer 'ON'
    delay(200);
    digitalWrite(0,LOW);  //Buzzer 'OFF'
  }
  
    Read_ADC();
  if ((temp>100)&&(temp<500))
  {
    //digitalWrite(6,HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Hot             ");
    digitalWrite(7,LOW); // LED "Hot" - Red 'ON'
    delay(200);
    digitalWrite(7,HIGH); // LED "Hot" - Red 'OFF'
    digitalWrite(0,HIGH);  //Buzzer 'ON'
    delay(1000);
 
               Read_ADC();
              if ((temp>100)&&(temp<500)) // scan adc value..if yes continue
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: STOP      ");
                  delay(1000);
                 } 
                  
                Read_ADC();
              if ((temp>100)&&(temp<500)) // scan adc value..if yes continue
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 10 Second   ");
                  delay(1000);
               }   
               
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 9 Second   ");
                  delay(1000);
               }  
              
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 8 Second   ");
                  delay(1000);
               }  
 
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 7 Second   ");
                  delay(1000);
               }  
 
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 6 Second   ");
                  delay(1000);
               }
 
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 5 Second   ");
                  delay(1000);
               }
 
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 4 Second   ");
                  delay(1000);
               }
 
                 Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 3 Second   ");
                  delay(1000);
               }
 
               Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 2 Second   ");
                  delay(1000);
               }
 
                Read_ADC();
               if ((temp>100)&&(temp<500))
               {
                  lcd.setCursor(0, 1);
                  lcd.print("Hot: 1 Second   ");
                  delay(1000);
                 digitalWrite(8,HIGH);  // Relay 'OFF'
                  delay( 1000);
               }
          
     }
  
  else
  {
    //digitalWrite(13,LOW);
    lcd.setCursor(0, 1);
    lcd.print("Normal        ");
    digitalWrite(7,HIGH); // LED "Hot" - Red 'OFF'
    digitalWrite(6,HIGH); // LED "Caution" - Orange 'OFF'
    digitalWrite(0,LOW);  //Buzzer 'OFF'
    digitalWrite(8,LOW);  // Relay 'OFF'
  }
  }
}
 
void Read_ADC()
{
   // subtract the last reading:
  total= total - readings[index];        
  // read from the sensor:  
  readings[index] = analogRead(inputPin);
  // add the reading to the total:
  total= total + readings[index];      
  // advance to the next position in the array:  
  index = index + 1;   // if we're at the end of the array...                 
 
    if (index >= numReadings)    // ...wrap around to the beginning:       
        index = 0;                          
  // calculate the average:
  average = total / numReadings;   // send it to the computer as ASCII digits   
   delay(1);        // delay in between reads for stability     
  float temp = ( 5.0 * average * 100.0) / 1024.0;
}
float temp = ( 5.0 * average * 100.0) / 1024.0;

You declare a variable and give it a value, but don't do anything with the value, mere microseconds before it goes out of scope. Did you mean

temp = ( 5.0 * average * 100.0) / 1024.0;

which would use the global of the same name?

(Better still would be to return the value from the function, rather than rely on a global)

const int numReadings = 1;

int readings[numReadings];      // the readings from the analog input

if i am not wrong, what should be average of 1 reading?

Yes, we all make simplifications to try to chase down the problem.

AWOL: float temp = ( 5.0 * average * 100.0) / 1024.0;

You declare a variable and give it a value, but don't do anything with the value, mere microseconds before it goes out of scope. Did you mean

temp = ( 5.0 * average * 100.0) / 1024.0;

which would use the global of the same name?

(Better still would be to return the value from the function, rather than rely on a global)

Thanks AWOL ... you are right.it work properly now... your really have sharp eyes...thanks alot..

You can change "numReadings" back to what it was now ;)

Khalid: ``` const int numReadings = 1;

int readings[numReadings];      // the readings from the analog input



if i am not wrong, what should be average of 1 reading?

sorry i put about 10 for read stability..i change it when i try to debug the problem..thanks anyway..