Constants characterizing digital pins, INPUT, INPUT_PULLUP and OUTPUT.

Pins configured as INPUT

The Arduino outputs (ATmega), configured by the pinMode() function as inputs (INPUT), are in a high-impedance state. This is equivalent to connecting to the output of a series resistor of 100 MΩ, so there are practically no requirements for the circuits connected to such leads. This mode is convenient for reading signals from sensors, but is not acceptable for powering LEDs.

It should be noted that the INPUT inputs are sometimes connected to ground through a pull-up resistor (a ground resistor), as described in the serial communication example.

Pins configured as INPUT_PULLUP

The ATmega Arduino microcontroller has internal pull-up resistors (resistors connected to the power supply inside the chip) that can be controlled. If you prefer to use them instead of external resistors connected to ground, use the INPUT_PULLUP parameter in the pinMode() function.

This will allow you to invert the behavior of the external sensor connected to the output: HIGH will mean its disconnection, and LOW – enable. See an example of using INPUT_PULLUP for serial communication.

Pins configured as OUTPUT

Pins configured by pinMode() as outputs (OUTPUT) are in a low-impedance state. This means that they can provide external circuits with a relatively large current. The ATmega microcontroller can transmit (positive current) or receive (negative) current up to 40 mA (milliamp) from external devices / circuits.

This mode is convenient for powering LEDs, but is useless when reading signals from sensors. Terminals configured as an output can also be disabled by a short circuit to earth or to a 5V power supply circuit. In addition, the ATmega microcontroller’s output current is not enough to power most relays and motors, which requires additional interface circuits.