2 state converter, from -24VDC [ON] - +5VDC [OFF] to 5VDC [ON] - 0VDC [OFF]
simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. Opto-isolator level shifter.

Opto isolators are great for this kind of application as there is no direct connection between each circuit.


With SW1 open D1 is off and Q1 is open circuit. '5 V logic' output is at 0 V.
With SW1 closed D1 turns on and Q1 pulls the output line to +5 V.