USB MIDI with toggle for button mapping

The SPDT switch is easy though it needs 2 pins. Your two switch positions could set a variable "transpose" to either 0 or 12 because to go up an octave you just need to add 12 to the note.. Then

        noteOn(0, notePitches[i], 100);

Change to

        noteOn(0, notePitches[i]+transpose, 100);

And change the noteOff similarly

That should do it. Or if you go with the button then each time it's pressed set transpose to 0 or 12, whichever it isn't now.

Steve