I have a question regarding the GPIO (from a Arduino board for example). How does it work exactly when you use it as an input pin? What are the mechanisms at work when you use it in a pull-up and pull-down resistor circuits with an push-buttons? I have read a few tutorials but they don’t give a deep explanation of the mechanisms, or I completely missed the points they were making. Most tutorials say things like (in a pull-up example), “When the button is pressed, it connects the input pin directly to ground. The current flows through the resistor to ground, thus the input pin reads a low state” (https://learn.sparkfun.com/tutorials/pull-up-resistors ). But in a pull-down resistor circuits with push-buttons, the input pin is also connected to ground when the button is pushed and the input is high in that case.
Also a baseline explanation would not work seem to work, because in case of a the pull-up example how does it know what the high/low value is when you have pushed in the button before connecting the power supply. Even a threshold explanation doesn't seem to explain it entirely, the voltage on the circuit as a whole seems to me to be above 2.5 V in both pushed and non-pushed state, when a 5V Vcc and 10kOhm resistor is used or is there an error in my thinking about this?
Explanations of electrodes that only travel through the pathway of least resistance also does seem to be right. Even if this was true this doesn’t explain the behaviour in the pull-down circuit, because there would never be any input when you would connect a 10 kOhm resistor to the ground (before the push button). Since this is lower than the impedance of the input pin (100k-1MΩ). Components divide the current according to their reciprocal resistances (I1 / I2 = R2 / R1). You can even see it when you connect a LED to the ground site of the circuit, which is on when you push the button and the input reads HIGH. Does in the pull-up case I1 / I2 = R2 / R1 explain the behavior, because there is no resistor in parallel to the resistor of the GPIO and because the connection where no resistor is present the resistance is neglectable (at least over a short distance), all current flow goes to the ground directly?
It seem to me it got something to do with the fact that the connection that has no resistor between the input pin (and the ground or power supply pin) determines the state when both have a closed circuit with it. But what is the mechanism. Does the GPIO unit (in input state) contain a sort of capacitor that “transmits” the charge to the power supply when it is directly connected to it (larger pull with larger voltage), and contains the charge longer (or replaced charge quicker) when it is directly connected to ground, and so influences the internal circuit? Or does it have something to do with the potential difference between the sides of a resistor, and if so how does the input pin read this?
I understand the fact that in you use a ground connection to the input pin (in a pull-down circuit) because otherwise the input pin would be influenced by noise (static) and a resistor because otherwise there would be a direct connection between the Vcc and ground, and this would result in a short circuit. So this part can be skipped in the answer. Of course you can add this in your answer for other users looking for an answer regarding this.
I hope that somebody can give me an (in-depth) explanation of how these circuits work.