Working of GPIO pins for INPUT and Pull up.down reistors

I'm sorry, I wasn't sure where to post this,
My question is regarding the basics of the GPIO pins present on the arduino.

Specifically I am talking about when the pinmode is set to INPUT.

My understanding is that the digital pins somehow detect the voltage on them, what I do not understand is the basic current flow , and what exactly happens, and how the input pin actually takes input. I believe that a 'input' pin isn't connected either 0V or 5V internally, then where exactly does the current go, and how is the voltage measured?

I read on the website that it has a high impedance, and so very small current flows through it, but where does the current go exactly, and how is the voltage detected?

Is there not a constant current flowing, but only motion of charges till the potential of both pins, the input pin and whatever pin it is connected to (0V/5V), doesn't become same?

Further I was confused regarding pull up resistors and how the voltage will be set in case multiple circuits seem to persist, as in the case when these resistors are used. I have the following doubts:

1)what does "weakly" pull up/down mean? does it mean that the voltage will actually not be 0V or 5V, and somehow only be weakly pulled towards the values(0V / 5V) and thus remain at some intermediate value between the minimum input voltage for HIGH and 5V / maximum input voltage for LOW and 0V. Or, does it imply that the voltage may start 'floating' in case of some high magnitude of interference, in other words, they do pull to 5V/0V, but they can't handle higher amounts of interference/ they'll only work properly with a low magnitude of external interference.

2)why is a resistor used, why not simply connect the input pin with the 0V or 5V pin.

3)If for example, I use the internal pull up resistor, and add a switch which connects the input pin with the GND, then when the switch isn't pressed, the only circuit arrangement present is the pull up one, so, somehow, the voltage at the input pin becomes 5V, now when the switch is kept pressed, there is another path for current available, so now there are two connections at the pin, one going to 5V via a resistor, other going to 0V via the switch, but in all tutorials i found that simply input was taken to be 0. What happened to the 5V pull up resistor now? how come it isn't significant anymore, and the reading simply changes from HIGH to LOW upon keeping the switch pressed?

I think for most of the part, I seriously require a good source/reference for beginners. But still, a detailed explanation would help me more!
Thank you for your time

Read this and ask what you still no not understand
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Specific answers are

  1. weekly means with a high resistor value so there is little current and a high impedance. This can be subject to noise.

2)you can but you would need a Chang over switch not just a single contact.

  1. the current flows through the pull up resistor to ground and the input is connected to ground. It is not significant because it does not affect the voltage on the input pin.
  1. Think of it like a voltage divider with the almost zero resistance of the closed switch being the second resistor. So at the point where all three are connected you'd see very very close to 0V. All of the voltage is dropped across the resistor.

Now think about it like a resistor divider with the almost infinite resistance through the open switch as the second resistor. Now almost none of the voltage is dropped across the pull-up resistor, all of the voltage drop is across the switch and you will see very very close to 5V at that point where all three connect.

A pin set as a digital input indeed senses voltage, but it isn't very precise: all we can
say (for a 5V Arduino) is that 3V and above will read as HIGH, 1.5V and below will
read as LOW, 1.5 to 3V range could go either way (this is the worst case assumption
you can make, in practice they will switch over near 2.5V). The input stage that
does this sensing is a CMOS gate with a small amount of hysteresis, effectively no
current is drawn except a very tiny amount when the voltage changes from 0 to 5
or back again, due to the input capacitance.

If you try to take the input below -0.5V or Vcc+0.5V then the protection diodes
will come into play and current can flow (and can cause damage, note).

Grumpy_Mike:
Read this and ask what you still no not understand
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Nice!
Last two paragraphs have the same title, penultimate should be pull UP

Nice!

Thanks.

mmcp42:
Last two paragraphs have the same title, penultimate should be pull UP

???
Penultimate title
Any disadvantages with using a pull down resistor?

Ultimate title
Any advantages with using a pull down resistor?

:slight_smile: