If the sensor output is open collector NPN you may only need a pullup resistor
Ditch the 12V.
Did the diode and internal pull up not work?https://forum.arduino.cc/index.php?topic=486601.0Leo..
the arduino does not have an internal pull up on the input im using.
Just saw the diagram in post#5.If correct, then connect a (~4k7) pull up resistor between Arduino pin and Arduino 5volt.And connect the sensor output directly to the Arduino pin.If this sensor is also connected to another unit, then only use a (~4k7) resistor between sensor output and Arduino pin. No internal pull up on the pin.Leo..
the only problem is that the second input that the sensor is connected to has an internal pull up to 12 volts