user33885: 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

user4143: The simplest and crudest method:
int val1 = analogRead(A0);
delay(5);
int val2 = analogRead(A0);

if (val2 > val1) {
    // It went up (for example).
}


33885: <p>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.</p>

<p>thanks in advance</p>
 4143: <p>The simplest and crudest method:</p>

<pre><code>int val1 = analogRead(A0);
delay(5);
int val2 = analogRead(A0);

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