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’ }; Declare an array for your analog pins: int analogInputPins(numberOfAnalogPins); Loop through the 16 pins: for(i=0;i<numberOfAnalogPins;++i) { analogInputPins(i) = analogRead( aiPins(i) ); if (analogInputPins(i) > highest) { highestPin = i; } if (analogInputPins(i) < lowest) { lowestPin = i; } }
Your highest and lowest pin numbers should now be in the highestPin and lowestPin variables.
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’ }; Declare an array for your analog pins: int analogInputPins(numberOfAnalogPins); Loop through the 16 pins: for(i=0;i<numberOfAnalogPins;++i) { analogInputPins(i) = analogRead( aiPins(i) ); if (analogInputPins(i) > highest) { highestPin = i;