I have nano connected with two momentary buttons and 2 relay module.
I programmed it , when the button 1 is pressed to switch on relay 1, delay some time and going back off and same for button 2 and relay 2. So far, so good it is work.
The main goal is never to have both relays switched on in the same time and my code work fine.
The problem is, that if the power is lost for very short time and nano is restarting , during this process on some check (i don't know what check) it switch on both relays in same time for short time, which is my issue. I have to avoid that.
If the power is out for more than 2-3 second and nano boot again - this problem is not persist.
As indicated in the the drawing, many of these relay shields work in reverse logic: if the IO is at 0V, then the relay is activated, please check if this is the case.
Then, it could be so that once your board boots, the IO is at 0V so the relay is activated.
Regarding the inputs:
You can decide to use INPUT_PULLUP instead of INPUT and use the switch to connect the IO to the ground. This way you can prevent stray signals from creating unwanted triggers.
ON power-on all IO-pins are in input-mode. This means a connectd device sees a "floating" voltage. To avoid this you can add an external pullup-resistor.
Pullup-resistor means one end is connected to +5V the other end of the resistor is connected to the IO-pin.
As long as the IO-pin is not defined as output the relay-modul gets 5V which keeps the relay switched off. If the IO-pin is defined as output and set to LOW the relay will switch on.
If your relay-board is HIGH-active you have to wire it opposite as a pull-down-resistor
best regards Stefan