Please excuse my beginner's question. Having read about electronics and logics basics and specific power-related questions, I've not found anything that would explain to me how to realize the following scenario.
I have a main circuit with an Attiny13, a few LEDs and FETs turning motors on or off. This circuit is powered by a 3.7V LiPo battery connected to Vin and GND.
I have a USB charging board that I can connect my LiPo battery to. I would like to use that. But I don't want to always unplug the LiPo from my board, but instead have the charger connect via a cable to it.
I am not looking for a parallel loading-and-running circuit. I am searching for an exclusive automatic switch acting like the following:
If there is power on my board's charging connector, cut off the main circuit and let the power only flow to my battery.
If there is no power on my board's charging connector, connect the main circuit and let the power flow from my battery through the circuit.
Since this is a small-sized PCB project, a ready IC would be great, but a few discrete components will do either. If you could explain to me, how to connect it and what to be careful with, that'd be nice.
Side question: Is it true that I should put decoupling capacitors between Vin and GND of my MCU, Vin and GND of my battery and between anode, cathode of every of my current drawing components (like LEDs)?