Tag Archives: bend

Interfacing Flex Bend Sensor with Arduino

Interfacing Flex Sensor with Arduino
flexsensor1

Introduction

‘Flex Sensor’ or ‘Bend Sensor’ is a sensor that changes its resistance depending on the amount of bend on the sensor. They convert the change in bend into electrical resistance – the more the bend, the more the resistance value.  Flex sensors are widely used in various applications such as – Automotive controls, Medical Devices, Fitness Products, Virtual Reality gaming consoles, Animatronics, Robotics, etc.  This tutorial aims to provide a detailed guide to flex sensor and its interfacing with Arduino.

Description

The Flex sensor patented technology is based on resistive Carbon elements. As a variable printed resistor, the flex sensor achieves great form-factor on a thin flexible substrate. When the substrate is bent, the sensor produces a resistance output correlated to the bend radius – the smaller the radius, the higher the resistance value.

This is how a flex sensor looks like:
flexsensor2

They are usually in the form of a thin strip from 1”-5” long that vary in resistance range. It is obvious that longer strip would give more number of different resistances on bending. The change in resistance with increasing bend is depicted in the below snapshot:
flexsensor3

In simple words, flex sensors are analog resistors. They work as variable analog voltage dividers.
flexsensor4

Inside the flex sensor are carbon resistive elements within a thin flexible substrate. More carbon means less resistance.

Usually a flex sensor is used in voltage divider configuration. It is shown below:
flexsensor5

Interfacing with Arduino

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. I 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.

Make the connections of the flex sensor in voltage divider configuration as shown above. Take your Arduino and connect the divider point to Analog Input of the board.

The analogRead() function will provide the sensor values.
flex = analogRead(1);
Serial.print(flex);

This will print values on the serial monitor.

Now we’ll show the amount of bend through LEDs. Connect the Red, Green and Blue LEDs to the Arduino Digital pins 4, 3 and 2 respectively, as shown in the circuit.

With no bend in the flex sensor, only Blue LED will Glow. When a small bend is applied, Green LED will glow (which is to indicate bend level). On applying large amount of bend, Red LED will glow, remaining two LEDs are OFF, which indicates large bend.

Circuit Diagram
flexsensor6

Images:
flexsensor7 flexsensor8

Code

#define blue 2

#define green 3

#define red 4

 

unsigned int f;

 

void setup()

{

 

pinMode(blue,OUTPUT);

pinMode(green,OUTPUT);

pinMode(red,OUTPUT);

Serial.begin(9600);

 

}

 

void loop()

{

f=analogRead(1);

Serial.println(f);

 

if(f>300)                          //No Bend; Blue LED Glows

{

digitalWrite(blue,HIGH);

digitalWrite(green,LOW);

digitalWrite(red,LOW);

}

else if((f<300)&&(f>260))          //Small Bend; Green LED Glows

{

digitalWrite(green,HIGH);

digitalWrite(blue,LOW);

digitalWrite(red,LOW);

}

else                              // Larger Bend; RED LED Glows

{

digitalWrite(red,HIGH);

digitalWrite(green,LOW);

digitalWrite(blue,LOW);

}

delay(50);

}