Switching between different Input configurations

Hi

I have 2 different switch mappings that i need to be able to switch between using a option switch.

If the option switch is HIGH do mapping A, and if it's LOW do mapping B

I was thinking of using void mapA and void mapB but not sure if that would work

Perhaps this code will do what you want to do:

// 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
}

what do you mean by "switch mappings"? pins and/or the state of the pins?

I have 5 outputs that are turned on and off at 2ms invervals one after each other and they are the same for both sets of switch configurations.

Mapping A has 8 switch inputs and depending on which input the 2ms pulse is on determines which relays are turned on.

With mapping B there are 16 switches that are using the same 8 inputs as mapping A but different relays are turned on.

I think it looks like a 5x8 switch matrix but not sure.

Thank you.

I will do a test to see if I can add some switches and outputs to that code and see what results I get.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.