0% found this document useful (0 votes)
50 views3 pages

Interfacing Flex Sensor With Arduino

The document discusses interfacing a flex sensor with an Arduino. A flex sensor is a variable resistor whose resistance changes when bent. To read the flex sensor, it is connected in a voltage divider with a static resistor. The Arduino measures the voltage across the static resistor to determine the sensor's resistance. The code samples show calculating the flex sensor resistance from the voltage reading and mapping it to a bend angle from 0 to 90 degrees.

Uploaded by

ks09anoop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

Interfacing Flex Sensor With Arduino

The document discusses interfacing a flex sensor with an Arduino. A flex sensor is a variable resistor whose resistance changes when bent. To read the flex sensor, it is connected in a voltage divider with a static resistor. The Arduino measures the voltage across the static resistor to determine the sensor's resistance. The code samples show calculating the flex sensor resistance from the voltage reading and mapping it to a bend angle from 0 to 90 degrees.

Uploaded by

ks09anoop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Interfacing Flex Sensor with Arduino

A flex sensor is basically a variable resistor, whose resistance varies when bent. Because the resistance is
directly proportional to the amount of bending, it is often referred to as a Flexible Potentiometer.

Flex sensors are typically available in two sizes: 2.2′′ (5.588cm) long and 4.5′′ (11.43cm) long.

Reading a Flex Sensor

The simplest way to read the flex sensor is to combine it with a static resistor to form a voltage divider,
which produces a variable voltage that can be read by the analog-to-digital converter of a microcontroller.

flex voltage divider

It is important to note that the output voltage you measure is the voltage drop across the pull-down
resistor, not the voltage drop across the flex sensor.
Code

const int flexPin = A0; // Pin connected to voltage divider output

// Change these constants according to your project's design

const float VCC = 5; // voltage at Ardunio 5V line

const float R_DIV = 47000.0; // resistor used to create a voltage divider

const float flatResistance = 25000.0; // resistance when flat

const float bendResistance = 100000.0; // resistance at 90 deg

void setup() {

Serial.begin(9600);

pinMode(flexPin, INPUT);

void loop() {

// Read the ADC, and calculate voltage and resistance from it

int ADCflex = analogRead(flexPin);

float Vflex = ADCflex * VCC / 1023.0;

float Rflex = R_DIV * (VCC / Vflex - 1.0);

Serial.println("Resistance: " + String(Rflex) + " ohms");

// Use the calculated resistance to estimate the sensor's bend angle:

float angle = map(Rflex, flatResistance, bendResistance, 0, 90.0);

Serial.println("Bend: " + String(angle) + " degrees");

Serial.println();

delay(500);
}

You might also like