lemming:
It would be easier to simple use a dedicated chip with all the logic (and safety) built into it like an MCP73831 or the like. There are breakout board on the net that are cheap.
Thanx but I want to use what I have I don't want to go buy chips. The exact same can be achieved with an arduino and 2 LM317's and some transistors and resistors.