Logic levels are detected by input pins. The difference between an input pin and an output pin is that an output pin has a specific voltage applied to it. An input pin does not, and when not connected to anything, it is in a high impedance, aka. a "floating", state which essentially means the voltage fluctuates randomly. This is the third state in 3-state logic, the other two being the binary 1/on and 0/off.1
When an input pin is connected to something, it's the voltage of what it is connected to that determines its state. If that thing is the ground of the circuit, its voltage will be relatively low and thus a logic level of 0.
That answers part of your question about the short circuit -- connecting an input pin to ground does not do so (but keep reading, because there is a potential short involved). However, it raises the question: How can the input end up "on" if the other wire is ground?
Let's look at that pull-up resistor diagram HeatfanJohn referred to.
Vin
and Vout
make this a little confusing in reference to which part is the "input" of the pin. Vin
refers to the place of highest voltage; current flows from there. When the switch is open, that current goes to Vout
, through the logic gate, so the state of the input pin is on. Consider this looking at an external pull-up resistor in a button circuit.
[Source: Adafruit]
- The red wire is 3.3v power connected to the + rail on the breadboard; this corresponds to
Vin
from the diagram.
- The green wire is ground, connected to the - rail on the breadboard.
- The yellow wire is connected to a GPIO input pin, and corresponds to the logic gate and
Vout
in the diagram.
When the button is down/the switch is closed, voltage flows from Vin
to ground, so the state of the pin, as determined by the logic gate at Vout
, is 0/off. The reason for the resistor is to prevent a short circuit -- from the output which drives this circuit (red wire/Vin
) and NOT the input (green/Vout
) where you are testing the logic.
The term "pull-up resistor" can thus be misconstrued if we take it to mean a resistor which affects the input pin. It doesn't affect the input at all. The actual "pull-up" (a connection to Vin
) is what affects it. The "pull-up resistor" is a safeguard on the pull-up.
The lesson here WRT to potential short circuits is don't accidentally set an input pin connected to ground as an output pin and drive it high.
1. Regarding that and something in your question: it is NOT 5V on the pi, it is 3.3V. There is a 5V output for powering 5V devices, but never connect that directly to any other GPIO pin or use it as the supply in a circuit such as we are discussing.