Connecting two programs into one

Welcome to the Forum!
Please insert your code using the code tags. You can go back and fix your original post.
Read the forum guidelines to see how to properly insert the code and some other good information on making a good post.

Regarding the problem - as far I see your codes contains a lot of delay() operators - it means that this codes can't be merged together.
You need to rewrite the codes first, getting rid all the delays.