# How does attaching analog inputs to digital pins actually works?

Hi

So obviously you can connect for example a LDR or a potentiometer to a digital pin and use it as a digital input but could anyone explain how it actually works. What does the switch value depends on and so on?

A digital input has a threshold voltage and hysteresis.

The values depend on the supply voltage. According to the data sheet for the ATMega328P (Uno), for 5V supply, anything above about 2.6V is considered HIGH, below about 1.8V is LOW.

In 2016 data sheets of ATmega328P, the electrical characteristics (Vcc = 5V, 850C) of a port-pin are:

VIL = 1.5V : max voltage that is guaranteed to be taken as LL
VIH = 3.0V : min voltage that is guaranteed to be taken as LH

VOL = 0.9V : max voltage that the port-pin will assume when LL is asserted on this pin
VOH = 4.2V : min voltage that will be sustained by the port-pin when LH is asserted on this pin

Hi,

Lots of Arduino Chip and Board details HERE: ArduinoBoardDetails - ArduinoInfo

Input pin specifics info HERE:
https://arduinoinfo.mywikis.net/wiki/ArduinoInputPinCharacteristics

Thanks for the help but I looked into the data sheets and I can't find the right info. Are you referring to this table?

Are you referring to this table

No. Look up pin input threshold (or hysteresis) for typical values.

Figure 29.3.9 in Rev. 8161D–AVR–10/09 of the ATMega48PA-88PA-168PA-328P data sheet.

"I/O Pin Input Hysteresis vs. VCC" and "I/O Pin Input Threshold Voltage vs. VCC"

So from what I understand you get your high voltage with 5V VCC like this. And it's there at 2.6V indeed.
But where do you read the low value on this? Same place, at Vcc = 5V. I get V(IL) = 2.2V from the ATmega48A plot you posted.

Oh, alright I got confused with the Y-axis Many thanks!