The Automatic Voltage Switcher utilises a diode, resistor and N channel Mosfet which allows automatic switching of the voltage sources if one of the sources is connected or disconnected.
R1 – 10K resistor 1/8W
D1 – Diode (schottky diode recommended)
Q1 – N Channel MOSFET (Gate source needs to less than the lower of the two voltage sources)
VCC-Low – Low voltage source (e.g 3V)
VCC-High – High voltage source (e.g 5V)
Make sure the difference in voltage between the VCC-Low and VCC-High is more than the diode’s breakdown voltage. I would recommend at least 1V difference.
How it works
Assume we have 2 voltage sources – 3V and 5V. When the 3V is connected, the 10K resistor connects to the Mosfet gate which gives it 3V so it turns on and allows the current to flow from the VCC through the load to 3V_GND. No current flows through the diode because it connection from VCC to 5V_GND which isn’t connected at the moment.
Once the 5V source is connected the 10K resistor and diode are both on however since 5V_GND is now active this means that it’s -5V at the end of the 10K resistor and diode. This turns off the Mosfet and allows the 5V to run through the load and not reach the 3V source because the Mosfet’s internal diode blocks the current flow.