Switching Micro-controller from Adapter power to Battery
One of the simple solutions is using Diode-OR (related question), you only need one-one serial diode after the two power lines, as follows:



As long as the voltage from the battery is less than the voltage from the AC/DC adapter D1 diode will conduct and as soon as the voltage from the AC/DC source disappears D1 will close and D2 will conduct.

Disadvantage is that you lose voltage over the diodes (diode forward voltage drop), I do not know if it is a problem in your case or your sources are high enough.

This was one a simple option which needs only two additional component, but you can use specific IC on supply switching purpose.

Example: TPS2115A

Typical application:


This solution need more component, thus more board-space, more expensive but here you do not lose voltage and it is more sophisticated.

There could be other ICs it was just an example as I said.