karlok:
However, I think if D5 is not GND, then 9V goes straight to A1 which is not good because it is limited to 5V. Dangerous?
Yes. I missed that, sorry. I was thinking that Vbatt was in a safe range, but it's not. And with a small R3 value, a problematic current flow could occur.
retrolefty:
Yes, best to drive a npn switching transistor to pull the voltage divider to ground.
I thing to get the A1 voltage in the safe range, the switching has to be done on the high side and with Vbatt > Vcc I think that would have to be an PNP eg: 2N3906 on the high side -- this is where I get fuzzy. Maybe a relay would be the simpler approach. In any event I think my trick of using output pins to supply the ground leg is not enough on its own to make this work.