How can I address the slaves for my master device?

Nope, I dont know my slave address. I am not talking about the device in which the addresses are hard coded.

I am working on microcontrollers. To be precise, I am working on STM32F103C8T6 with STM32 official core in Arduino IDE.

Since all the 4 microcontrollers are identical, I would like assign one microcontroller as master and all others as slave. To achive this, I read about MODBUS protocol in internet and implemented the MODBUS protocol with RS485 using serial pins in microcontroller. Since all the microcontrollers are same, I belive they all must have same address (correct me if I am wrong). So, I added dip switches to the microcontroller where I could able to change the address of the microcontroller using dip switch.

So, when I have several slaves, then I should give each slave with unique address with which master can communicate to the respective slave device.

Somewhere in internet, I saw that it is possible to assign slave address with dip switches for microcontrollers.

My question was how can I assign slave address to my slave device with dip switch? and how to implement this in programming?