What happens when you apply 5V to input pin - pull up resistor?

Hello,
I’m trying to understand how digital inputs work. I’ve applied 5V to the digital input pin on my Arduino before. Nothing bad happened. I read that the digital input has a “pull-up resistor” - is that what keeps the current low running into the input pin? But you have to set the resistor on in the sketch, and I’ve never done that.

Or does the input pin “naturally” have very high input impedance, just because of the way they’re made? Sorry to sound so amateur, I obviously know nothing about it.

On the megas, they're defaulted to inputs so they wouldn't need declaring.

Any pin set as an input is considered to be in a high impedance state, and as a result of this is very sensitive which makes them great for low powered and weak sensors. think photodiodes.

A pullup resistor, is connected from the input to 5V, a pulldown resistor is connected from the pin to Negative. This forces the input to be in a HIGH or LOW state, which will help avoid random changes to the state due to electromagnetic fields and other intereference. (Remember, its sensitive!. The resistors simply make the switch stronger in both states giving more predictable results)

To all practical purposes an input pin has infinite resistance (certainly 10^10 ohms or more). They just sense voltage.

The Atmega chips have weak internal pullups (defined as 20K to 50K). There are no pulldowns. Applying 5V to an input with a pullup resistor enabled has no effect - reading the pin will return a HIGH. If the 5V was not connected it would also read HIGH. If the pin was then pulled low by another device, or by a switch connected to Gnd, it would read as LOW.

With no resistor connected, internal or external, the pin requires only 1uA to change it's input level.

IIL Input Leakage Current I/O Pin, VCC = 5.5V, pin low (absolute value): 1 ?A

IIH Input Leakage Current I/O Pin, VCC = 5.5V, pin high (absolute value): 1 ?A

CMOS devices, the class of semiconductor to which the ATmegas - and almost all current computing devices - belong, uses "insulated gate" FETs in which the gate is separated from the channel by a thin layer of dielectric, usually silicon dioxide.

As such, in normal operation, the gate draws no current from the circuit to which it is connected, except to charge or discharge its intrinsic capacitance, of the order of a few picofarads. As the dielectric could be damaged by excess voltage however, protective silicon diodes are formed into the chip between each external gate connection, Vcc and ground which conduct if the gate voltage strays more than a diode forward voltage either above Vcc or below ground, to protect against electrostatic discharge (ESD).

Finally, the internal "pull-up" is a rather small FET device added into the port circuitry between the port pin and Vcc and controlled by the output latch so that it is turned on if you write a logic "HIGH" to that latch even when the primary output drivers are disabled by setting the Data Direction Register to define it as an input. This will source a fraction of a milliamp (as a fairly constant current source) to anything that tends to pull the input pin below Vcc (or arguably, will draw the same current from any source that tends to pull it above Vcc by less than the protective diode drop as these FETs are generally symmetrical).

Unless that pull-up is enabled or the voltage strays outside of the supply limits, the input impedance is very high indeed, noting two quotes people have previously offered (presumably) from the datasheets, as a minimum of 5 megohm (1?A leakage) and a typical of 10 gigohm.

The input current of a CMOS gate is mainly due to the reverse-biased junctions
of the input protection diodes, which is absolutely negligible at room temperature
(order of < 0.1nA) but will rise exponentially with temperature to 175C (maximum
junction temperature of most silicon devices). The datasheet input leakage specs are
usually given for the chip’s whole temperature range (which may be upto 125C or so).

1uA leakage worst-case at 125C isn’t unremarkable, but the room-temperature leakage
will be many orders of magnitude less unless the input diodes have been damaged.

Without protection diodes the leakage current is perhaps < 1pA. But the device would
be destroyed by touching the pins.

To simplify the answers:-

arusr:
I read that the digital input has a “pull-up resistor” - is that what keeps the current low running into the input pin?

No.

arusr:
Or does the input pin “naturally” have very high input impedance, just because of the way they’re made?

Yes.