returning lowest value from an array

Hi all,

I am having some difficulty with a 0-5v analog signal; It has some random voltage spikes that are interfering with my program. Since I know the low values are correct and what I want, I was thinking I could set up an array to take 100 readings and then allow me to use the lowest value to use in my program; and keep doing this repeatedly ( possibly a few times a second?) Unfortunately I have no clue how to go about making the code for this. Can you guys help me? I know you're not supposed to ask for this kind of thing on here, but I would be grateful if someone could possibly write something that I could more or less plug into my existing code? Thanks in advance.

Andrew

If you're only going to use the lowest, there is no need to use an array.

For example:

int Lowest;
int CurrentReading;
int i;

Lowest = 1024;   // Guaranteed to be higher than any actual reading
for (i = 0; i < 100; ++i)
{
  CurrentReading = analogRead(Pin);
  if (CurrentReading < Lowest)
    Lowest = CurrentReading;
}

I never thought of doing it like that, that makes it really simple. Thanks!

So now I can just apply your "Lowest" value into my code for analysis, if I am looking at this correctly.