user33966: What I want to know is that how exactly does analogRead work because I have want to use it with a flex sensor and it has only two pins.I tried to find other examples on the internet, but this is the only example I find.If the middle pin of the 10k potentiometer and a0 pin are shorted or the gnd  pin is removed altogether,then would this thing work? 

user20245: I think you are confused because the ADC input measures voltage, not resistance.  
To convert from resistance to voltage you need to pull in the opposite direction on the variable resistance with a fixed resistor.  As in the following image from this tutorial.


33966: <p>What I want to know is that how exactly does analogRead work because I have want to use it with a flex sensor and it has only two pins.I tried to find other examples on the internet, but this is the only example I find.If the middle pin of the 10k potentiometer and a0 pin are shorted or the gnd  pin is removed altogether,then would this thing work? </p>
 20245: <p>I think you are confused because the ADC input measures voltage, not resistance.  </p>

<p>To convert from resistance to voltage you need to pull in the opposite direction on the variable resistance with a fixed resistor.  As in the following image from <a href="https://learn.sparkfun.com/tutorials/flex-sensor-hookup-guide" rel="nofollow noreferrer">this tutorial</a>.</p>

<p><a href="https://i.stack.imgur.com/UkqHA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UkqHA.png" alt="enter image description here"></a></p>
