When input becomes high (24V) or low (ground,) I want digital pin1 connect to ground. I designed this. Is it correct and safe for use in a car with a car battery?

I want digital pin swapped between unconnected and grounded. So:

1. If Input = High --- > DP1=ground
2. If input=Low -------> DP1=ground
3. If input=Unconnected ------->DP=unconnected

It’s designed to detect car's door opened / closed in different car systems.

[![enter image description here](https://i.stack.imgur.com/5i0PN.jpg)](https://i.stack.imgur.com/5i0PN.jpg)

My new solution: I use a switch so thr user can select input, ground or Vcc.

[![enter image description here](https://i.stack.imgur.com/Hqi82.jpg)](https://i.stack.imgur.com/Hqi82.jpg)