display only data that has changed

Ok, I am trying to do something that has me a bit confused. I only want to display data on the lcd or serial monitor if the data has changed. Example. If the temperature stays constant at 90 deg F, I don't want the serial monitor to constantly send 90 one billion times. I have tried the not equal (!=)but I am at a loss at the moment. As for the LCD, to wont matter to me if it keeps sending the data. The serial part is going to an excel sheet, and only need it up dated when it changes to something else.

Something like this should work:

int oldVal = 0;
int newVal;

void loop()
   newVal = 12; // Somehow, newVal gets a value
   if(newVal != oldVal)
      // send newVal to excel, lcd, etc.
      oldVal = newVal;

If not, post your code, and explain what problems you were having with the != operator.

This appears to work great! Thank you for the quick reply paul