I checked seven pages of google search, couldn't find what I'm looking for.
Which is: a utility which would scan a sketch and produce a list of the I/O pins used and whether they're configured as input or output and whether any are duplicates.
I was thinking this would be useful when merging code.
Should be straightforward to write a Python program to do that if the coder has been careful to use pinMode() for every pin. But it is not necessary to use pinMode(pin, INPUT) so it would also probably be necessary to check every digitalRead() and analogRead()
It would at least list all the lines you need to check.
Then there's the problem of libraries which set the pinMode internally - e.g. SD.h
It isn't difficult to do this yourself since you just need to search the code for "pinMode" and then make a list of the pins that are referenced.
BTW, this doesn't handle the analog pins which don't need to have pinMode set.
I think it's better to just have a section at the start of your sketch where you define a variable for every pin. This is best practices so you should be doing that in all your code anyway. You can split the definitions into sections according to the usage of the pin if you want. If there are pins used by libraries that the sketch includes then you can define those pins also, even though they're not used in the sketch, or just add a comment for each. Then when you want to merge code you just compare the pins definitions for each sketch to make sure there are no duplicates.
for (int i = 0; i < numOfInputs; i++) {
pinMode(inputPins[i], INPUT); // set 8-11 as inputs with pullups [0]=8, etc.
digitalWrite(inputPins[i], HIGH); // pull-up 20k
}
I guess it'll just be the search-and-make-a-list technique.
pert:
I think it's better to just have a section at the start of your sketch where you define a variable for every pin. This is best practices so you should be doing that in all your code anyway. You can split the definitions into sections according to the usage of the pin if you want.
Robin2:
Of course if you are writing all the programs yourself what @pert says is excellent advice.
Even if you're merging code that you found somewhere else, you're still going to need to modify it in order to do the merge so going through the code to de-magic-number all the pins should be the first step.
The ability to highlight all instances of a word is the feature I miss most when using the Arduino IDE.