Switching from different sources using a microprocessor
A relay will do it. Though it may be more proper to describe it as a relay module, because you can not use a relay alone and switch it with a microcontroller. 

Be careful switching from parallel to series, if the timing and/or design is wrong you'll short out a battery.