How do I get the boolean code, true or false, for this sensor?


Oh, very nice colour! :grinning:

Too much complete nonsense about semantics.

We have a schematic of the device. It has three wires. Two of them are for power; you can call them what you like, I for one do not care but you need to provide between 6 and 36 V to them. There is an open-collector driver connected between the negative wire and the output wire.

So the negative wire connects to negative of the power source, say 12 V, and the positive to the positive of that power source. That is all that is needed to do (to supply power). That power source will also have its negative connected to the Arduino negative or "GND". The output wire should be connected to an Arduino input but to be absolutely safe, you do so via a diode with cathode to the sensor and anode to the Arduino input. You may or may not need a pull-up on the Arduino input to its own Vcc (5 V) given that you will use INPUT_PULLUP in pinMode to enable an effective 45k pull-up.

Now, the diode means that the input can only be pulled down and in this configuration, there is no more negative point in the circuit than "ground" so it can never be pulled down below ground. On the other hand, the diode prevents any positive voltage being conveyed to the Arduino, so it is totally safe.