int currentValue; // global variables are retained on each iteration of loop()
int previousValue;
int analogPin=0;
void setup() {
}
void loop() {
previousValue = currentValue; // store what was read last time
currentValue = analogRead(analogPin); // get a new reading
if (previousValue != currentValue) { // compare them
// do something, they are different
} else {
// do something else, they are the same
}
}[/code