# Comparing multiple Arduino inputs

Hi,

This is probably very simple, but is there an easy way to find which of multiple arduino inputs is greatest/least?

All I can think of is using lots of  if/else's. I tried googling it but found no relevent results.

I am thinking of between 10-16 inputs, so if/ else's would not be very practical.

Thanks,

## Comment viewing options

Thanks heaps Birdmun,

You have saved me alot of trouble. Thanks for the quick replys.

That looks good, thanks, but I think it may be missing something,

Declare variable for highest: int highest = 0;
Declare variable for lowest: int lowest = 1023; //1023 for 10bit ADC, 255 for 8bit (I hope :) )
Declare variable for highestPin and lowestPin: int highestPin, lowestPin;
Declare variable for number of analog pins: int numberOfAnalogPins = 16;
Declare an array for your analog pin numbers: int aiPins(numberOfAnalogPins)={ 'enter the pin numbers here separated by commas' };
Loop through the 16 pins: for(i=0;i<numberOfAnalogPins;++i)
highestPin = i;

}

lowestPin = i;

}
}

Without these, wouldn't both highest+lowestPin Both end up as 16? (Provided 16 is not 1023 or 0)

Correct me if I am wrong.

Thanks for your input, looks promising

Cheers,

All I can really say is, I saved you a whole batch of if/then statements. :P
And, all you had to do was debug my semi quick code. :)

do you mean you are looking at analog lines or digital? I find it difficult to believe an arduino has more than at best maybe 10 analog lines and I believe that is pushing it (I was wrong the 2560 has 16 analog pins. For the sake of argument, try something along these lines (Disclaimer: I don't know arduino)

Declare variable for highest: int highest = 0;
Declare variable for lowest: int lowest = 1023; //1023 for 10bit ADC, 255 for 8bit (I hope :) )
Declare variable for highestPin and lowestPin: int highestPin, lowestPin;
Declare variable for number of analog pins: int numberOfAnalogPins = 16;
Declare an array for your analog pin numbers: int aiPins(numberOfAnalogPins)={ 'enter the pin numbers here separated by commas' };