analogRead over a certain time I would like to read an analog value using analogRead, save this value and compare it to an analogRead value 5 ms later. How would this code look? Because giving a variable the value of analogRead(A0); would mean it is constantly changing, making it impossible to compare two values.

thanks in advance
The simplest and crudest method:

int val1 = analogRead(A0);
delay(5);
int val2 = analogRead(A0);

if (val2 &gt; val1) {
    // It went up (for example).
}