// The switch that changes the mode of the other switches
const byte switchPinMapping = 2;
// The other switches
const byte switchPinA = 3;
const byte switchPinB = 4;
const byte switchPinC = 5;
void setup() {
// I assume all switches connected between their defined pin and Gnd
// so we need pull up resistors on the pins
pinMode(switchPinMapping, INPUT_PULLUP);
pinMode(switchPinA, INPUT_PULLUP);
pinMode(switchPinB, INPUT_PULLUP);
pinMode(switchPinC, INPUT_PULLUP);
}
void loop() {
// Notes: The mapping switch has to be held closed (LoW) to select OptionB.
// There is no debounce code
// If you want a push of the mapping switch to toggle the mapping then ask how to do it.
if (digitalRead(switchPinMapping))
// Mapping switch not pressed
processSwitchesMappingA();
else
// Mapping switch pressed
processSwitchesMappingB();
}
void processSwitchesMappingA() {
// put your code here for processing switches A,B, and C
}
void processSwitchesMappingB() {
// put your code here for processing switches A,B, and C
}