Using USB for power supply and make the 9V a backup?

If I connect both of them to the board, can I default to using the USB for power and have the 9V as sort of a 'battery backup'?

Would it do that automatically if they are both connected? Or would you have to handle that in programming?

My project might be the simplest thing ever performed by an Arduino. When the program is run, all it does is stroke a servo 180 deg. with some specific delays. Once.

Thanks.

Assume this is an UNO.

Vin overrides USB power.


One option.

You will need to make up an external circuit.

An external 12v wallwart to power jack, then 9v battery thru a diode to Vin might work.


Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

Have the wallwart power the board and a relay. When wall power turns off the relay flips power to the battery...