Values from Vex bumper switch

I have a bumper switch on digital port 1.
The switch is sending 0 when pressed, and 1 when not pressed.
This is the reverse of what is stated in the Vex docs.


Is it necessary to do anything with


prior to reading digital ports?
(Using latest PROS on MacOS 10.11.4)

You are tying the pin to ground when pressed, hence the 0. It reads 1 when not pressed because of a pull up resistor. This is the same behavior as most platforms, but what documentation are you referencing? On RobotC, a digital input acts this way, while a touch sensor is inverted.

That’s normal behavior.
Usually you’d call pinMode(1, INPUT); in init.c

Just program using those values

Just curious, why is it that the touch sensors (bumper and limit) are inverted?


0 being pressed is counter-intuitive I agree, but it’s dictated by the hardware and makes sense knowing how the circuit is constructed

Thank you @creatorthomas.

There is actually an industrial/controls reason for this, and VEX is just following industry practice. These various switches are often used to control the limits of moving equipment, or for detecting when a safety gate is closed. By requiring a limit switch or sensor to give an “active” signal when the machine is in the “all ok” position (for example, when all safety gates are closed, the signal is active), one can detect a malfunction such as broken, cut, or disconnected wires. In this case, a cut wire to a safety switch would act the same as the safety switch tripped.

So the logic of a VEX switch: it will return “true” when it is plugged in and operating normally. If it became cut or unplugged (in addition to being tripped), it will return “false.”

@knnohn - Many thanks for the clear explanation. Makes sense. It is nice to know what is going on under the hood, and why.