## Flex Sensor 2.2" - Small Retail

Thank you for purchasing a SparkFun Flex Sensor! This unique component can sense how much it is being bent. It opens up a wide range of projects, including:

...and other uses limited only by your imagination.

## How it works

One side of the sensor is printed with a polymer ink that has conductive particles embedded in it. When the sensor is straight, the particles give the ink a resistance of about 30k Ohms. When the sensor is bent away from the ink, the conductive particles move further apart, increasing this resistance (to about 50k Ohms when the sensor is bent to 90º, as in the diagram below). When the sensor straightens out again, the resistance returns to the original value. By measuring the resistance, you can determine how much the sensor is being bent.

## How to use it

NOTE: Although the active portion of the sensor (the area between the black squares) is quite sturdy, the pin-end of the sensor is susceptible to kinking and eventual failure. We recommend reinforcing or securing this area (for example, clamping or gluing down the sensor at the black square nearest the pins) to ensure that this area doesn't flex along with the rest of the sensor.

The simplest way to incorporate this sensor into your project is by using it in a voltage divider. This circuit requires one resistor. Many values from 10K to 100K will work, but we'll use a 10K resistor here (SparkFun part number COM-08374, also supplied in our Inventor's Kits and locally at Radio Shack, etc.). Connect the flex sensor to your microcontroller using the following circuit:

The resistor and the flex sensor form a voltage divider, which divides VCC by a ratio determined by the two resistances. When the sensor is straight, the 10K resistor and the 30K flex sensor will cause the output voltage to be about 75 percent of VCC. When the sensor is bent, the voltage will increase to about 83 percent of VCC (see our voltage divider tutorial for the math). If you're using 5V for VCC, you should see about 3.75V when the sensor is straight, and about 4.17V when the sensor is bent by 90º. These numbers will vary for individual sensors; for the most accurate results, test your specific sensor and use those numbers in your code.

Here's a basic Arduino sketch to show the output from your sensor:

```    // Flex sensor test program
// Mike Grusin, SFE, 2011
// This program is free, use it however you wish!

// HARDWARE:
// Make the following connections between the Arduino and the flex sensor
// Note that the flex sensor pins are interchangeable

// Sensor pin - GND
// Sensor pin - Analog In 0, with 10K resistor to +5V

// INSTRUCTIONS:
// Upload this sketch to your Arduino, then activate the Serial Monitor
// (set the Serial Monitor to 9600 baud)

void setup()
{
// initialize serial communications
Serial.begin(9600);
}

void loop()
{
int sensor, degrees;

// read the voltage from the voltage divider (sensor plus resistor)

// convert the voltage reading to inches
// the first two numbers are the sensor values for straight (768) and bent (853)
// the second two numbers are the degree readings we'll map that to (0 to 90 degrees)
degrees = map(sensor, 768, 853, 0, 90);
// note that the above numbers are ideal, your sensor's values will vary
// to improve the accuracy, run the program, note your sensor's analog values
// when it's straight and bent, and insert those values into the above function.

// print out the result
Serial.print(sensor,DEC);
Serial.print("   degrees: ");
Serial.println(degrees,DEC);

// pause before taking the next reading
delay(100);
}
```

## Tips

• The sensor works only in one direction: when it is bent away from the side with the conductive ink (towards the side with the text). You may see a small response when bending in the other direction, but not nearly as much as in the "correct" direction. (If you need to measure bending in both directions, consider using two sensors back-to-back).
• Manufacturing tolerances will result in some variability between individual sensors. For the most accurate results, you may want to calibrate the sensor you're using by measuring its values at various positions, and using those numbers in your code.
• These sensors work best (and last the longest) if they are bent across a large radius, not kinked. Remember that the active area is between the black squares.
• As noted above, the pin-end of the sensor is susceptible to kinking and eventual failure. We recommend reinforcing or securing this area so that it doesn't flex along with the rest of the sensor.

## Have fun!

• If you guys don’t mind me asking, which techniques did you use to connect the exposed silver traces? From what I’ve learn, one shoudn’t solder directly into it.

• Yeah, i lost 3 flex sensor in the soldering… anybody knows how to properly connect the silver traces?

• I bought five flex sensors 2.2", all work in the same range from 30k to 36k. Maybe I need a new multimeter

• I have bought two flex sensor2.2. When them did not bend, the one is 25.4k, the other is 19.5k. They are so big different, why? And according to datasheet, the sensor produces a resistance output correlated to the bend radius. What is relationship between resistance and bend radius?

• So I followed the sketch, but my flex will not work unless I switch the ground and VCC connections. Any ideas?

• hi!can you tell me how to calibrate flex sensor?

• If you are using arduino use the map() function: http://arduino.cc/en/Reference/Map

• Will it work pluged to 3.3V instead of 5V?

• Yes!

• can you tell me how to calibrate flex sensor

• hrmmm…. im gonna try it out on my atari punk! and i second that on the 4.5, should be prettymuch the same but id imagine the resistance is different.

• Es una buena recomendación.
Atentamente,