How to make an Arduino-like thingy charge like a mobile device?

First post here. I'm trying to make a simple MCU-based lamp which can be used without constantly plug in, so I want to have some rechargeable AA batteries (six of them so it should be about 7.2V) on the bottom. And since it's my very first project, I decided to use Uno Rev3's schematic as the major reference -- to build something similar but only contains what I actually need.

However, while I'm doing some research on posts, I found that power management may not work as I originally thought -- from what I read, Uno will always draw power from the batteries if it's higher than 6.6V, which I assume it will always ignored the external power supply until batteries are drained to that point.

What I'm planning are similar to laptops or any mobile device -- when external power supply plugged in, it will always draw power from there until you unplugged it. Therefore, I can maximized the battery life out of my lamp, and only using batteries when necessary.

So I wonder, if there's a way to achieve that, and do I also need some software to manage that well?

Your way is complex.

Simpler to run the MCU from the batteries all the time. When the charger is connected then it runs the device and any leftover current charges the battery.

If you use a switched jack to plug in the battery charger/power supply, you can disconnect the "unconnected" path for powering the arduino lamp off batteries. You can use a diode to charge the batteries while the connected. I have attached a crude schematic.

charger.png

Sounds like I can handle in either software and hardware.

I'll try then, thanks.