[Help] How do you store only the first reading of a variable?

I am making a project to measure the speed of sound in various solids, and I need to know How do you store only the first reading of a variable if it is read multiple times?

I am using an Arduino Uno if that matters.

You save the first reading in a variable then compare it to a new reading. If they are different then update the variable, if not, then discard it.

Use another variable as a "flag" to mark whether the value has been saved or not. When it is saved the forst time change the flag. Something like this pseudo code ...

valueIsSaved = false;

loop() {
  tempValue = analogRead(12); // or whatever

  if (! valueIsSaved) {
     savedValue = tempValue;
     valueSaved = true;


Just don't write it again:

void loop() {
     int initialValue = analogRead(12);

    value = analogRead(12);
   // do stuff, but leave initialValue alone

[barney]... or.... OR....[/barney]

Read and save in setup(), read but never save in loop()