I am making a device based on a STM32F105 (3v3) that has to accept inputs that I am not in control of, for example in a vehicle or other wiring that I cannot change.
The device is to have 16 inputs.
I want the input to be selectable between active low and active high. Because sometimes I might come across a switch that is switched to GND and sometimes one that is switched to say 30v.
All inputs have to be 30v tolerant.
I would like to have the option of selecting in firmware whether the input is connected to a switched Ground or switched positive.
How can I go about accepting inputs that could be switched GND or on other occasions be switched 24v?
For example I may come across either of the following so I need my circuit to be able to accept both: