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

Hi,
The choice of colours for that sensor are very misleading.
An industry standard is RED = Positive Supply, BLUE = GND Supply, BLACK = Negative Supply, WHITE or YELLOW = Signal.

In this case see below.


And as suggested, use a pullup resistor.

Tom.. :slight_smile: