How to control the power in and out of the battery