help needed to switch pin7 and pin8 over and back with a button.

I’ve built a 32 note keyboard for tuning a midi pipe organ, not to play just to help with tuning, all the midi side is working fine, but I need 40 keys not 32. As I’ve used a 74hc757 shift register its simple to add more keys so its all set up to play 40 keys and all I have to do is switch between two pins with a switch to get another 12 keys that works fine, not the best way to do it I know. So I started programming a push button to drive a small changeover relay to do the job all good but still not the best way.

My question is can one switch pin inputs with a pushbutton with Arduino?

I can have one bank of switch returns from the keyboard on Arduino pin7 and the other on pin8, I use pin2 for the button that can operate a relay on pin13 (HIGH). I would like the button on pin2 to switch pin7 to pin8 and stay till the button is pressed again (LOW) switching pin8 back to pin7 like the relay or switch will.

Any help please.

If you are using a declared constant in your digitalRead()s like you should, you can switch by simply making it a variable, and changing the pin number variable to select a different pin.

If you find that confusing, perhaps you should post your code.

any example please, i know what your saying but implementing it all is doing my head in, i've only ask as a last resort, i've read what i can find but all i get it button led routine. thanks