Hello, I'm on my school project using pressure sensor.
I want to program the arduino to ;
print Serial on Serial monitor when the sensor value goes over or less the threshold (let, 500)
for example, if sensor receives [ 20, 34, 300, 511, 677, 523, 201, 33, 560, 702, 45, 10] (delay 1000)
then [511, 201, 560, 45] is printed.
I was thinking to save the right before value in new variable (let, int past = 0;)
and compare it to new value received by sensor (let, int new = 0;) and the code would be like;
if(past>500){
if(new<=500){
Serial.println(new);
} delay(1000);
}else if (past<=500){
if(new>500){
Serial.println(new);}
}
My question is,
What function should I use to save the real time sensor values updated every seconds?
Or is there any other way to treat threshold limits?