What is actually read by Arduino?

Hi there!

So I have a simple code which uses a flex sensor, whose resistivity increases when bend.

const int flexPin0 = A0; //pin A0 to read analog input
int value0;

void setup(){
Serial.begin(9600);
pinMode(flexPin0,INPUT);
}

void loop(){
value0 = analogRead(flexPin0);         //Read and save analog value from
Serial.print (value0);
}

What I'm trying to understand is what is actually the value value0 (which shows around 250-300)? Is it the resistance of flex sensor but mapped onto 1024 bits? If so, why does it decrease when bend?

Tq for your help.

The output of analogRead() is a number from 0 to 1023 that is proportional to the voltage on the analog pin. Normally 1023 equates to 5v when the Arduino is powered with 5v (such as from the USB port).

AFAIK the flex sensor is equivalent to a potentiometer except that you bend it rather than rotating a knob.

...R

If you have connected your sensor as a half (full?) bridge, the location of the sensor in that circuit determines increasing or decreasing values. Without further signal conditioning the Arduino measures the center voltage of the bridge.