Switching between 2 or more sketches

Can I toggle between 2 or more sketches?

///////////////////////// SKETCH #1 /////////////////////////////
//Arrays to 2 PIN I/O:
int outPin[] = {2,3};
int inPin[] = {22,23};
int pin_size = 2;
int loop_count = 0;
int voltage;

void setup() {
    lcd.init(); 
    lcd.backlight(); 

    //initialize the digital pin as an output or input:
    pinMode((int)outPin, OUTPUT);
    pinMode((int)inPin, INPUT);
    
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0,0);
    lcd.print("welcome");

    lcd.setCursor(0,1);
    lcd.print("by: HERE");
    delay(10000);
    lcd.clear();
      
}

void loop() {   

    // Send the outputs.
    digitalWrite(outPin[loop_count], HIGH);  
    delay(100);              
    digitalWrite(outPin[loop_count], LOW);    
    delay(100);              

    // Receive the inputs:
    voltage = digitalRead(inPin[loop_count]);
    
    lcd.print ("Wire " + String(inPin[loop_count]) + ": ");

    // LCD prints PASS or FAIL status using a switch statement:
    switch (voltage){

        case HIGH:
            lcd.print("PASS");
            break;

        case LOW:
            lcd.print("FAIL");
            break;

        default:
            lcd.print("UNKNOWN");
    }
    
    // Delay and increment the loop counter for the next set of pins.
    delay(1000);
    loop_count++;
    lcd.clear();

        // Check if reached the end of all pins.
    if (loop_count == pin_size){
        lcd.print ("Test Completed");
        delay(2000);
        lcd.clear();
        lcd.print("Testing again...");
        delay(1000);
        lcd.clear();
        loop_count = 0;
    }
}

}

///////////////////////// SKETCH #2 /////////////////////////////
//Arrays to 4 PIN I/O:
int outPin[] = {2,3,4,5};
int inPin[] = {22,23,24,25};
int pin_size = 4;
int loop_count = 0;
int voltage;

void setup() {
    lcd.init(); 
    lcd.backlight(); 

    //initialize the digital pin as an output or input:
    pinMode((int)outPin, OUTPUT);
    pinMode((int)inPin, INPUT);
    
    // set the cursor to column 0, line 1
    // (note: line 1 is the second row, since counting begins with 0):
    lcd.setCursor(0,0);
    lcd.print("TEST");

    lcd.setCursor(0,1);
    lcd.print("by: TEST");
    delay(10000);
    lcd.clear();
      
}

void loop() {   

    // Send the outputs.
    digitalWrite(outPin[loop_count], HIGH);  
    delay(100);              
    digitalWrite(outPin[loop_count], LOW);    
    delay(100);              

    // Receive the inputs:
    voltage = digitalRead(inPin[loop_count]);
    
    lcd.print ("Wire " + String(inPin[loop_count]) + ": ");

    // LCD prints PASS or FAIL status using a switch statement:
    switch (voltage){

        case HIGH:
            lcd.print("PASS");
            break;

        case LOW:
            lcd.print("FAIL");
            break;

        default:
            lcd.print("UNKNOWN");
    }
    
    // Delay and increment the loop counter for the next set of pins.
    delay(1000);
    loop_count++;
    lcd.clear();

        // Check if reached the end of all pins.
    if (loop_count == pin_size){
        lcd.print ("Test Completed");
        delay(2000);
        lcd.clear();
        lcd.print("Testing again...");
        delay(1000);
        lcd.clear();
        loop_count = 0;
    }
}

}

No, but you could create one sketch that can be switched between both usages.

Basically the first sketch is contained in the second, only the number of pins changes.

That'll help too, where do I start? Thanks

How do you want to change modes?

This does not what you expect it to do.

You could use

    for (auto pin : outPin) {
      pinMode(pin, OUTPUT);
    }
    // no need to set INPUT mode, that's the default state 

button switch press once to run checking 2 pin, press again to checking 4 pin...etc..

So you could start by programming that.
The setup function for the 4 pin variant includes the initialization for the 2 pin variant,
so you don't have to change configuration between switches.

I would suggest using a state machine for the test steps and get rid of the delays.

I like the Bounce2 library to handle buttons.

Too advanced for me.

That is not how i want

Good luck with your approach.

Could you briefly describe the function of the two sketches. These both appear to be some sort of continuity testing sketches. Probably, you should build one purpose built sketch instead of attempting to integrate two separate but similar sketches.

what input determines which routine to run?

Either between toggle switch

which pin?

It is continuity tester. But i have different type of conductors.
1 of them with 2 pins, and the other 4 pins. It kinda sucks when i had to build 2 Arduino for both. I know there is a way for this

so what in the hard determine which test?

I guess you don't know what i am talking about?

strange way to ask for help

I am sorry i don't mean that, but i kept repeating the answer to all relies. I hope you did read my topic from above. The hard part i can't call function switch between 2 options:

  1. Press switch to check 2 pins, results past fail.
  2. PRESS switch again to check 4 pins and those functions are in my both sketches from 1st topic.

which switch, which pin?