rechargable batteries for uninterruptible power supply

Ok now I understand.

gardner:
so you might have to use larger values for R3 and R4

This goes for R1 and R2, too?

And I changed the resistance values of R3, R4.
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?
If D5 is GND then I understand how it works, is digitalWrite(5,LOW) really the same as attaching something to GND?
I attached the schematics like I understood it.