Pin modes: INPUT, OUTPUT, INPUT_PULLUP
What pinMode() does electrically, and which mode to use.
| Mode | What the pin does | Use for |
|---|---|---|
| OUTPUT | Drives 0 V or the logic voltage (≈20 mA max) | LEDs (with resistor), driver inputs, signals |
| INPUT | High impedance — reads whatever drives it | Sensors that drive the line, buttons with external resistors |
| INPUT_PULLUP | Input with an internal resistor to the logic voltage | Buttons and switches to GND |
| INPUT_PULLDOWN | Input with an internal resistor to GND (ESP32 only) | Buttons to 3.3 V |
Two outputs connected together, one HIGH and one LOW, short each other. Never wire output pins directly to each other, to GND or to a supply.