Finding pre pre value from continuous sensor reading.

This may be a odd or really stupid question... but i am having trouble comparing the current reading from a sensor to the previous previous reading....

500 --> comparing this
300
200 --> to this

I am able to compare the previous values but am confused about the prepre value :confused:

i tried this:

void detectGreen()
{
ppColor = preColor;
color = analogRead(4);

if(color < ppColor - 50);
   Stop();

preColor = color;

delay(60);

but it works the same as comparing the previous value to the current value...

So i was hoping someone could help me out with the obviously wrong logic it would be much appreciated!

Thank you!

It worked! Thank you... yeah it makes sense once you go through it. I wish i had a debugger would make stuff much easier. Also the semi colon was just a typo, i prefer to not use {} when i can to keep the code looking 'clean', and yeah i only want the Stop() to be part of the if statement.

Thanks

I would suggest that you put your samples in a short circular array, and then you can find any of the recent previous samples easily.