Merging Two Codes?

I would add the following to concept in @BillHo's link

Most short Arduino sketches are configured like this

void setup() {
    // all the setup stuff for programA
}

void loop() {
   // the meat of the programA
}

If you reorganize that structure like this

void setup() {
    // all the setup stuff for programA
}

void loop() {
   myFunctionA();
}

void myFuntionA() {
    // the meat of the programA
}

Then most of the work of merging two projects can be reduced to

void setup() {
    // all the setup stuff for programA
    // all the setup stuff for programB
}

void loop() {
    myFunctionA();
    myFunctionB();
}

void myFuntionA() {
    // the meat of the programA
}

void myFuntionB() {
    // the meat of the programB
}

...R