On newer Arduinos, one can set pinMode to one of three states: OUTPUT
,INPUT
, and INPUT_PULLUP
.
This page says:
The Atmega chip on the Arduino has internal pull-up resistors (resistors that connect to power internally) that you can access. If you prefer to use these instead of external pull-down resistors, you can use the INPUT_PULLUP argument in pinMode(). This effectively inverts the behavior, where HIGH means the sensor is off, and LOW means the sensor is on.
I'm rather sure that inverting the behavior isn't the only thing that it does, though.
What does INPUT_PULLUP
do? What makes it different from INPUT
, and how does one decide which one to use?