Ender 3 ignores signal from optocoupler
Not knowing the type of inductive sensor you are using, the most common, an NPN type sensor (like the LJ18A3-8-Z/BX) is assumed (in relation to your previous question). NPN type sensors imply that the signal is held high at a certain voltage (the supply voltage ranges from 6 V-36 V, but are reported to work on 5 V also) and is actively switched down to 0 V when triggered.
Basically the sensor always produces a high signal until triggered. Why is this the preferred option? If somehow the wires break or some issue occurs that triggers the sensor, movement is stopped to prevent damage to occur.
The signal from the sensor needs to be &quot;high&quot; and the switch needs to cut the power by opening the circuit. So make sure what your sensor signal is outputting in the first place. The depicted switch is a powered switch as it uses an LED, but the switching component on the circuit board itself has three pins, COM (COMmon), NO (Normally Open) and NC (Normally Closed). You need to put +5 V on the white wire to power the right side of the optocoupler and connect the switch as such that the COM and the NC are connected (most probably S and U in the depicted switch).