These 3 diagrams represent 3 test cases.
Dia 1:
When I perform an analogRead
of analog port 0, then I get a high value obviously. According to the manual, the analogRead
method obtains the resistance. I expected it would say that it returns the voltage. Anyway, in this case both are directly proportional.
Dia 2:
With a resistor + pull-down resistor, the reading of the analog port 0 decreased.
Dia 3:
However, I would have expected that dia3 would also result in a decreased value.
My reasoning was: The supplied voltage of 5V is constant. So, it must be divided between the resistor and analog port 0. A bigger resistor should result in a higher voltage for the resistor, and a lower one for the analog input. --> But that seems to be incorrect.
Second attempt: The analog port reads resistance and not voltage. Maybe that's important. R = V / I
. Apparently the resistance remains the same. So, applying this formula: if resistance remains constant and voltage decreases, then it could be caused by an increasing current. But it doesn't make sense that the current would increase by adding a resistor.
PS: if I add the analog pin to ground, then I get a low reading.
Where exactly is my reasoning flawed ?
EDIT:
As many people have pointed out. I have indeed wrongfully interpreted the following phrase in this tutorial. Thank you for pointing that out to me.
in the main loop of your code, you need to establish a variable to store the resistance value.