I have a project that uses 21 inputs and 21 outputs. For some debugging I am writing a simple program that give's me the pin number when an attached button is pushed, through the serial.Print fuction. All is working well but it is a lot of copy paste and then changing numbers. Isn't there a more convinient way to do this?
See attached code (I do need to change some numbers for it to work)
It would have been easier all round if you had posted your code here instead of attaching it. As it is I have not looked at your code but the answer is almost certainly to use an array of pin numbers and a for loop to read the inputs and output the number of the pins when you find a button pressed.