Can I make the BT module disconnect with a BT module and connect with another in the code? I am working on a project that requires a connection between two BT modules (HC-05) and a mobile phone. Later on, I encountered a problem: I can't connect two BT modules to one at the same time, So I thought about the possibility of ending a connection and starting the other one when needed. If that was possible, how can I do that in an arduino code?  

One of the BT modules is a master which means it can't connect to the phone and it has to be a master because it must be connected to the other slave BT module.
Send AT+ROLE=1 to BT module to set module into master role.
To set module back to slave mode, send AT+ROLE=0

Also check this video, you have source code in the description. It will help you understand how to do it.