Post History
The difference between your two options is which polarity the input floats to when left open, and whether there is an overall inversion. Adding the inversion in the firmware would require one more...
Answer
#1: Initial revision
The difference between your two options is which polarity the input floats to when left open, and whether there is an overall inversion. <blockquote>Adding the inversion in the firmware would require one more pin from the chip.</blockquote> Not necessarily. I was envisioning inversion or not would be specified by configuration data stored in non-volatile memory. This is how PLCs do it. Physical switches are rather klunky. Assuming you really want to do it the klunky way, I'd separate how the line floats from adding the inversion. The inversion part is simple. You already have a digital signal at the collector of the transistor. Running that thru a XOR gate before presenting it to the micro allows for optional inversion. Adding an optional pullup to the input changes the voltage at which the line floats. 100 kΩ to 24 V at IN is enough to easily turn on the transistor. Now the question is how to add the pullup and change the level of the second XOR gate input with a single jumper or switch. Have the switch either connect a node to 24 V or not. That works directly for the pullup. A resistor divider from there to the XOR gate can change the 0-24 V into 0-3.3 V. For example, 100 kΩ pullup with 16 kΩ to ground would work. One last issue is that you don't want high voltage on the input back-driving the pullup node and changing the polarity of the XOR input. The solution is to isolate each with a diode: <img src="https://electrical.codidact.com/uploads/40vtjb92zzjgb3evfbux1qq7q0z5">