How does on 'Input' pin work? (beginner question)

I've been going through some beginning tutorials, and got stuck around the idea of a 'pull down/pull up' resistor. I'm trying to use the same configuration as this guy: Why do I need a pull down resistor in the button example? - General Electronics - Arduino Forum .

My question is this: When a pin is set to 'input', does that literally mean current (conventional flow) is flowing 'in' to the pin? I.e., is this 'input' pin functioning like a new ground?

And a follow up question, is the pull-down resistor just so the connection isn't shorted when the button is pushed? In the other thread, other posters said that the input pin needs to be connected to the ground so it isn't 'floating'. Could you then achieve the same effect by just connecting the input pin to the ground without a resistor, and only have the 5V output from the board connecting through the resistor? My confusion was if the pin is acting as an 'input' and you have a 10k resistor, wouldn't the pin then be shorted because there's no resistance in that direction (but this is based on my assumption, which I think is wrong, that the input pin is acting like a ground).

Thanks

Input means you can read data on the pin into your sketch variables.

Time to read this:

When a pin is set to 'input', does that literally mean current (conventional flow) is flowing 'in' to the pin?

No.

Read:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

larryd:
Input means you can read data on the pin into your sketch variables.

Time to read this:
Gammon Forum : Electronics : Microprocessors : Switches tutorial

From the pull up section:

This resistor "weakly" pulls the switch up to +5V, so that if the switch is open, it will have 5V on it (through the resistor) and thus will register HIGH if not pressed, and LOW if pressed.

What does it mean to have 5V on it? I think my confusion is with voltage. If the output is 5V, and the pin has 5V, wouldn't the Voltage be read as 0 because theyre the same relative to each other? That's why I was thinking the pin acts as a ground, because I thought they're needed to be difference in order for there to be voltage.

wouldn't the Voltage be read as 0 because theyre the same relative to each other?

No.
The input detects a voltage. If that voltage is above 0.7 of the supply voltage it reads as a HIGH logic level. If that voltage is below 0.3 of the supply voltage it reads as a LOW logic level. Anything in between is indeterminate.

That's why I was thinking the pin acts as a ground, because I thought they're needed to be difference in order for there to be voltage.

And that is why we told you that you are wrong.

All voltages are referenced to the ground potential.

The input resistance of a pin is >100mega ohms.
Next to no current flows through the 10K (therefore no voltage drops across it) which means almost 'all' of the 5volts supply appears on the pin itself.

The applied voltage equals the sum of the voltages in a cct. to GND.
5Vcc = V10K + VinputPin
5Vcc = 0 + VinputPin
VinputPin measured to GND is the full Vcc i.e. 5V
.

alanza55:
What does it mean to have 5V on it? I think my confusion is with voltage.

Your intuition is spot-on, a single point in a circuit cannot have a voltage(*), its sloppy language.
What is meant is that the potential (ie voltage) between that point and the 0V reference (usually
called ground) is 5V.

We almost always measure relative to the same implicit 0V point in the circuit and don't bother
to spell it out every time.

(*) well strictly speaking it can, but measuring it (the absolute electric potential) is beyond utterly impractical.

Grumpy_Mike:
No.
The input detects a voltage. If that voltage is above 0.7 of the supply voltage it reads as a HIGH logic level. If that voltage is below 0.3 of the supply voltage it reads as a LOW logic level. Anything in between is indeterminate.
And that is why we told you that you are wrong.

All voltages are referenced to the ground potential.

What is the voltage of the pin relative to the ground potential in the case of the pull down resistor?

alanza55:
What is the voltage of the pin relative to the ground potential in the case of the pull down resistor?

pinMode INPUT
pin----[10K]----GND will read zero volts on the pin to GND.

pinMode INPUT_PULLUP
pin----[10K]----GND will read ~1 volt on the pin to GND. (depends on the value of the internal pullup resistor)

.

larryd:
pinMode INPUT
pin----[10K]----GND will read zero volts on the pin to GND.

pinMode INPUT_PULLUP
pin----[10K]----GND will reads ~1 volt on the pin to GND. (depends on the value of the internal pullup resistor)

.

When you say "reads zero volts", do you mean the pin itself is 0 volts (relative to ground)? I guess this goes back to my original confusion. If it's zero volts relative to ground, then wouldn't the pin itself would be 0 volts relative to the 5v on the board (since the 5v is also measure 'relative to ground)? Therefore the input pin would be acting like a ground and drawing current?

In electronics, we 'almost always' measure voltages relative to GND (0volts)

When you say "reads zero volts", do you mean the pin itself is 0 volts (relative to ground)?
Yes, relative to ground.
It measures 0 volts to GND, it is not GND (0 volts).

I guess this goes back to my original confusion. If it's zero volts relative to ground, then wouldn't the pin itself would be 0 volts relative to the 5v on the board (since the 5v is also measure 'relative to ground)?
It is at -5 Volts relative to Vcc (5V)

Therefore the input pin would be acting like a ground and drawing current?
No

Normally you place the Black lead (common) from a voltmeter on GND (0 volt) and the Red lead on the point that you want to measure your voltage.

If you reverse the leads you then get a reverse reading.

You really need to cover some basic electronics courses, lots on the web and YouTube.

Please review these:
https://learn.sparkfun.com/tutorials/how-to-use-a-multimeter/measuring-voltage

https://www.youtube.com/results?search_query=voltage+measurement

.

Suggestion: get yourself a bunch of say penlight batteries of nominal 1.5V but it would be good if some were old and some brand new so you have a range of voltages from say 0.5 to 1.6 or whatever.

Measure their individual voltages and mark them on some masking tape on each battery. Maybe even mark an arrow on each cell pointing to the pip. Now line them up, flat end to pip, and measure the voltage from the bottom flat to the top pip. Note the voltage: it should be the sum of the individual cells' voltages. Reverse the leads: same number but -ve? The meter takes the black lead as its reference point, its zero. That's a local zero for that test: not an absolute zero in some greater cosmic sense.

So with black on the bottom flat you get the top pip being say 4V "higher"; with the black on the top pip, the bottom flat is 4V "lower".

Now, poke the black lead into a join in your battery string: measure from there to the very bottom and very top, and any other joins. Taking into account the signs (ie the pip of each cell being "higher") and your arrows, and the difference numbers noted on each cell, verify that the readings make sense.

Then fool around:

Do that with the meter black on a different join in the string.
Mix the order of the batteries in your string
Reverse one of the cells so its pip is on another's pip (it might be difficult to get the flats to mate nicely but you could stick a bit of folded tin foil in to connect them)

In all cases make sure that the arithmetic sum (ie, accounting for the direction of the arrows) of the known individual voltages agrees with the value and sign on your meter.

NOW find another bunch of batteries and make another string. Connect the lowest flats, the very bottoms, of the two strings to each other with a wire and do some measurements: measure within each string and across strings. (Take the inter-connecting wire away and measure across strings: what happens?)

Move the wire into the middle of one of the battery strings. Measure some more. Mix the orders of the batteries in the strings, and battery arrow directions.

You'll find that in all cases, taking into account the individual numbers , the direction of the battery arrows, and the position of your black lead as your local zero, everything stacks up arithmetically.

(I'm thinking that would make a handy video. Mix in a switch or two and a some pullup/pulldown resistors, and that's a very handy tutorial.)

alanza55:
Therefore the input pin would be acting like a ground and drawing current?

I see hinting from the other people, but no one has explicitly addressed this misconception of yours:

Pins set to INPUT do not draw current.

There are caveats to this of course. The current is not literally zero, but it is low enough (nanoamps) that it can be ignored in almost all cases. It also requires the input voltage to be between the power supply voltages (cannot be less than 0 or more than VCC). As long as you aren't doing crazy things with the pin, you can safely assume that no current is flowing into or out of it at all.

If it's zero volts relative to ground, then wouldn't the pin itself would be 0 volts relative to the 5v on the board (since the 5v is also measure 'relative to ground)?

If the pin's voltage is zero volts relative to the ground, it would also be accurate to describe it as minus five volts relative to the 5V on the board.

Indeed that is what you would read if you put your DVM's black wire on the 5V and the red wire on the ground.

Alright, sorry guys; you aren't rid of me yet. I'm really trying to understand how the mechanism for measuring the input voltage works. Is it essentially a tiny voltmeter that measures the voltage drop across the input pin to ground? I sketched the diagrams for the two cases to ask a few more questions (let me know if the diagrams are incorrect; i know a pin doesn't go directly to ground, but i'm assuming the pin to be whatever internal circuity that eventually returns to ground). Based on what you guys have told me and what I've read other places, this is what I've put together so far. (also, I used a capacitor to represent the pin because I couldn't find a similar component in the program i used)

I think I am clear on the pull down case. When the switch is open, both sides of the input pin are connected to ground, so there is no difference in voltage (both at 0V relative to ground). Thus if you were to take a voltmeter and measure 'across the pin', it would read a voltage drop of 0. But once the switch is closed, you now have a parallel circuit, so each 'branch' has 5 volts across it to ground. Therefore, since the pin (or whatever total mechanism is measuring the voltage from the pin to ground) is the only component in this branch, the voltage drop across it would be the total 5V. (And the resistor in the other branch is only for the sake of preventing a short).

The pull up case is less clear to me. When the switch is open, I see how the pin is always connected to the 5 volts. However, since it is in series with the 10k resistor, would not the voltage drop be occurring primarily over the resistor itself? The only seeming solution to this I found online was that the pin itself has a resistance of around 100k ohms; thus, if this is true and using ohms law, the voltage drop across R2 would be just ~0.45 volts, and the remaining ~4.55 volts would be 'dropped' across the input pin. This would resolve my confusion of the switch open case.

But, if this switch is closed, it seems like as far as the input switch is concerned, the circuit is the same. Since we again have a parallel circuit, with the voltage across each branch being 5V.

1 Like

alanza55:
The pull up case is less clear to me. When the switch is open, I see how the pin is always connected to the 5 volts. However, since it is in series with the 10k resistor, would not the voltage drop be occurring primarily over the resistor itself?

No voltage drop since no current is flowing when the switch is open, and inputs take negligible current
(a few picoamps at most)

The only seeming solution to this I found online was that the pin itself has a resistance of around 100k ohms;

Greater than 10^10 ohms at room temperature for typical CMOS inputs.

thus, if this is true and using ohms law, the voltage drop across R2 would be just ~0.45 volts, and the remaining ~4.55 volts would be 'dropped' across the input pin. This would resolve my confusion of the switch open case.

But, if this switch is closed, it seems like as far as the input switch is concerned, the circuit is the same. Since we again have a parallel circuit, with the voltage across each branch being 5V.

When the switch is closed the pin is at 0V, since the switch has a few milliohms resistance compared
to the pull-up resistor's 10k.

Basically the resistances involved are radically different - input pin 10^10 or more, pullup 10^4, switch 10^-2.
The smallest resistance in the circuit will totally win.

With the switch shorted the switch wins.
With the switch open the pullup or pulldown wins
With no switch and no pullup/down the pin floats (the high resistance of the pin is battling
against the capacitive coupling from nearby signals and stray static electric fields from insulators, and
its not small enough to win).

Ah, I think I finally understand now (and a few people had mentioned this earlier but I didn't catch on until now): the resistance on the input pin is so high that the voltage drop across it outweighs the voltage drop across the 10k resistor. The other error I made (in pull up case) was calculating the current through the input pin branch by assuming 5V because it was a parallel series. I should have first calculated the resistance of the two branches in parallel using the formula: (R1^-1+R2^-1)^-1. Which tends to 0 as the resistance in a branch tends to 0 (button closed). Therefore, the only component with resistance can be considered to be the first resistor, so the voltage drop across it is the entire 5V. Thank you!

If you replace those capacitors representing the input pin with a much more realistic resistor of 100M then I think you have got it, and it will be easier to see.

Note as MarkT said no current through a resistor means no voltage is dropped. In the case of a pull up their is a tiny current through the 100M resistor equivalent of the input pin. So as a professional would say, sod all current so sod all voltage drop.

Input pins are probably much higher resistance than that at room temperature - the leakage current of the protection diodes and output drivers rises exponentially with temperature, datasheets quote the worse case across the full temp range usually.

The original CMOS logic family inputs with no protection were an astonishing 10^13 ohms or so, once you
add in some reverse biased pn-junctions from the output FETs and protection diodes its more likely to be
10^10 ohms area when cold, falling with increasing temperature.

Anyway for logic circuits this is as near to infinite as makes no odds.