I have a device that runs off of three D batteries. I would like to be able to add a power cord so that I can plug it into the wall and run it off of that instead. I would also like to still be able to automatically run it off the batteries on the off chance that the power goes out or I need to move it, but that is secondary and not as important. What would I need to get to do this?
In my case, the device has an input of "DC4.5V 500mA" and the cord that I am planning on using is from an old phone charger and it has an output of "5.1V ⎓ 0.7A".
I would imagine that if I just wanted to power it from the cord, I could just cut the wires from the battery case and solder the red to red and the black to the black. But, because the cord outputs 5.1V, would that short out the 4.5V input? If I put in a resistor, could that prevent it from happening? How many ohms would it need to be?
That would still not help me with the lesser issue of the power going out. How could I wire it so that I would still have the batteries but not run off the batteries until needed. I think I would need a logic gate, but I don't know enough to know what to use and then how I would need to wire it up.
Any advice for a novice would be greatly appreciated.