Imagine the typical "blink without delay" program", but instead of switching the state of a LED you would like to read the current value of a float.

The value of the float is constantly changing and every 3 sec. i would like to read the current value of the float.

This value is then compared to the last value (the 3 sec old float). We could, for instance, subtract one from the other and get at third value as a result.

This third value is the compared to the next occuring "third value" and so on.

If we see three identical "third values" in a row (meaning that the float has changed in a linear manner for 9 sec) i would like to "do something" with a simple IF statement.

But i'm having a hard time realizing how to save these "third values" into different floats and then overwriting them again once i have spent 3 (or perhaps a bit more) of them.

It isn't a good idea to compare floats for equality, better to allow a little "wobble-room" of a small fraction of the possible range of the values. The abs macro is useful here.

you could store the incomming values in a four element array and compare the three differences
when a new value arrives overwrite the oldest data and compare again
be careful comparing floats, it is not like comparing integer whole numbers
real number accuracy depends on the number of bits used to store the floating point data
a technique is to subtract the values, take the absolute value of the result and see if it is less than some ‘error’ value, e.g.

But how can i store the float's before comparing them? I have to store the value (difference between current value and last value) for some time in different floats, them to compare them.

Will discrete groups of 3 values be tested or will it be done on a rolling test of the 3 most recent values ?

Either way, do the values have to be floats, because of how they are held they are not accurate beyond a couple of decimal places so you may need to ignore less significant decimal places. How many decimal places are significant in your application ? Where do the values come from and is there any chance of them being sent as integers which are easier to compare successfully.

TolpuddleSartre:
It isn’t a good idea to compare floats for equality, better to allow a little “wobble-room” of a small fraction of the possible range of the values. The abs macro is useful here.

Depends what is generating the floats.

horace:
you could store the incomming values in a four element array and compare the three differences
when a new value arrives overwrite the oldest data and compare again
be careful comparing floats, it is not like comparing integer whole numbers
real number accuracy depends on the number of bits used to store the floating point data
a technique is to subtract the values, take the absolute value of the result and see if it is less than some ‘error’ value, e.g.