I am using a barometric sensor to sense a sudden drop or sudden rise in pressure in a given period.
For example the difference reading could be "-.300" or "+.300"; is it possible to read just to the right of the decimal point and use the sign to indicate fall or rising?
William
Delta_G:
Math....
Keep up with the last reading. Subtract the new reading to get the difference. If the difference is greater than 0.3 then your condition has been satisfied.
I have coded the difference function and have it working. How can I detect the sign of difference value to indicate fall or rising? Now building the alarm...
You could determine sign by comparing to 0:
if(difference < 0) // difference is negative.
You could get rid of the negative number with the absolute() function:
difference = abs(difference);
Getting rid of the decimal point is another matter not in my tool bag yet.
Good luck.
There are just 3 possibilities - the difference is 0, it is +ve or it is -ve
This code should sort it out
if (difference == 0) {
// do the zero stuff
}
else if (difference > 0) {
// do the +ve stuff
}
else {
// do the -ve stuff
}
...R
Thank you klubfingers and Robin2 will try out your methods.
Attaching sample from data collection; just difference collection.
William
Difference.txt (3.17 KB)