LED hangs up

While comments are good they can also be made unnecessary by using good constant and variable names. What constitutes "good" symbol naming will vary from person to person and organization to organization.

Also the use of constants can reduce the memory requirements (sometimes considerably).

// Arduino Thermostat using the TMP36 temp sensor chip
// This code uses a rolling average to smooth the output of the TMP36 to give
// accurate temperature control by turning on fans or a heating bulb to keep a
// constant temperature range. Three LEDs show the state of the heat and cool
// relays, as well as the "all OK" state.

// --- GLOBAL CONSTANTS

const uint8_t   pinSENSOR_THERM = A0;       // set the input pin for the TMP36 to Analog pin 0
const uint8_t   pinRELAY_HEAT   =  4;       // set heat relay trigger pin to digital pin 4
const uint8_t   pinRELAY_COOL   =  8;       // set cool relay trigger pin to digital pin 8
const uint8_t   pinLED_OK       =  7;       // set all OK led pin to digital pin 7

const uint8_t   RELAY_OFF       = LOW;
const uint8_t   RELAY_ON        = HIGH;

const uint8_t   LED_OFF         = LOW;
const uint8_t   LED_ON          = HIGH;

const int       setTemp         = 77;       // set desired temp to 77F
const int       numReadings     = 25;       // set the number of reading to average


// --- GLOBAL VARIABLES

//     (COMPLIER WILL ZERO ALL GLOBAL VARIABLES WELL BEFORE 'SETUP' IS CALLLED)

int             readings[numReadings];      // the readings from the analog input
int             index;                      // the index of the current reading
int             total;                      // the running total
float           voltage;                    //  variable for raw temp reading from TMP36
float           average;                    //  variable coverted to millivolts
float           tempC;                      //  Varible for millivolts converted to degrees Celsius
float           tempF;                      //  variable for degrees Celsius converted to degrees Fahrenheit

void setup()
{
    Serial.begin(9600);

    pinMode(pinRELAY_HEAT, OUTPUT);
    digitalWrite(pinRELAY_HEAT, RELAY_OFF);

    pinMode(pinRELAY_COOL, OUTPUT);
    digitalWrite(pinRELAY_COOL, RELAY_OFF);

    pinMode(pinLED_OK, OUTPUT);
    digitalWrite(pinLED_OK, LED_OFF);
}

void loop()
{
    total = total - readings[index];        // subtract the last reading:
    readings[index] = analogRead(inputPin); // read from the sensor:
    total = total + readings[index];        // add the reading to the total:
    index = index + 1;                      // advance to the next position in the array:

    Serial.print(readings[numReadings]); Serial.println(" numReadings ");

    if ( index >= numReadings )             // if we're at the end of the array...
    {
        index = 0;                          // ...wrap around to the beginning:
    }


    // calculate the average:
    average = total / numReadings;          // calculate the average:
    voltage = (average * 5000) / 1024;      // convert raw sensor value to millivolts
    voltage = voltage - 500;                // remove voltage offset
    tempC   = voltage / 10;                 // convert millivolts to Celsius
    tempF   = ((tempC * 1.8) + 32);         // convert celsius to Fahrenheit

    Serial.print(tempF); Serial.println(" degrees F");
//  Serial.println(tempC);                  // send the temp in Celsius to the computer (as ASCII digits)
//  Serial.println(tempF);                  // send the temp in Farenheit to the computer (as ASCII digits)


    // if the current temp is 8 degrees lower than the setpoint
    digitalWrite(pinRELAY_HEAT, ((tempF < (setTemp - 8)) ? (RELAY_ON : RELAY_OFF)));


    // if the current temp is 8 degrees higher than the set point
    digitalWrite(pinRELAY_COOL, ((tempF  > (setTemp + 8)) ? RELAY_ON : RELAY_OFF))


    // if the temp is less than 8 degrees above the set point and less than 8
    // degrees below the setpoint
    digitalWrite(pinLED_OK, (((tempF <= (setTemp + 8)) && (tempF >= (setTemp - 8)) ) ? LED_ON : LED_OFF));

    // delay in between reads for stability

    delay(300);
}