I need help combining these two codes

Please read this
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/681310

Then go back and post your code accordingly. The way you posted your code is unacceptable here.

Then read and understand this
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html