While loop that fills smallest and biggest number in Array

Is it possible to run a while loop for 50ms, that keeps reading out a Analogue Sensor and that stores the smallest and biggest number it gets in an array.

If i Have an array: int MinMaxVal[1];

that the while stores int MinMaxVal[0] with the smallest and int MinMaxVal[1] with the biggest.

I feel its possible, but i'm kinda stuck on how to compare inside the while loop.

Your array has only one member. You need:

 int MinMaxVal[2];

The pseudocode is unchallenging - if it's smaller than the smallest, store it, if it's larger than the largest, store it. :slight_smile:

Exactly the same way as comparing outside a while loop.

Paul