Hello guys (and gals)!
I'm trying to figure out how to program thresholds using my arduino board.
Essentially, to make this as simple as possible, this is what I have going on.
I am sampling a value every one second, I am taking the value and trying to make certain actions occur based on when this value crosses certain thresholds.
The value read every second will be a value between 0-150.
The thresholds will work something like this:
If value crosses over 20 and becomes 20 or higher, do an action.
If value crosses over 20 and becomes 19.9 or less, do a different action.
And then do the same for a threshold at 30, 40, 50, and 65.
I would need to have it so that if it reads a value of 15, and then a second later, reads a value of 23, it does an action. But if it reads 23, and then reads 24 a next, it needs to not do anything because it hasn't crossed over from one threshold to another. I only want an action to perform if a threshold is crossed either by increasing or decreasing past it.
So again, to reiterate;
If first value read is 34, and second is 42, do an action.
If first value is read at 57, and second at 44, do an action.
If first value is 24, and second value is 26, do nothing. (no threshold was crossed)
The next part would be figured out if a threshold was crossed twice, or more, to do that action twice or more times.
Any advice on how to code this?
Thanks in advance.