I want to connect a NS04-N limit switch to a Nano. The limit switch requires a voltage of 10-30 volts to work correctly. The output from the limit is too high for the Nano, so I thought of connecting it through an optocoupler like a PC218.
If I connect the NS04 to a 12 volt supply and take the signal out which is 12 volts to a PC218 opto with the appropriate dropping resistor, and then connect the collector of the opto to the Nano 5v pin and the emitter of the opto to the limit pin on the Nano, would that work OK?
I am not sure about this type of connection or the values of the resistors needed if someone can help me please.