Interfacing Flex Sensor with Arduino

Introduction 

A flex sensor uses carbon on a strip of plastic to act like a variable resistor. The resistance changes by flexing the component.
The sensor bends in one direction, the more it bends, the higher the resistance gets.
In this project we will use a flex sensor to fade an led.

What is a Flex Sensor?

flex sensor or bend sensor is a sensor that measures the amount of deflection or bending. Usually, the sensor is stuck to the surface, and resistance of sensor element is varied by bending the surface. Since the resistance is directly proportional to the amount of bend often called flexible potentiometer.

The Flex Sensor used in this project is shown in the following image. It is about 0.6cm wide and 8cm long (including the two connectors).

Since a flex sensor is basically a resistor (whose resistance varies depending on its bend), it has two terminals (or leads).

Coming to the variable resistance part, an unflexed sensor i.e. a flex sensor as rest, exhibits a normal resistance value. In my case, the normal resistance of the Flex Sensor is around 60KΩ.

When I bend the sensor as shown in the following image, the resistance increases with the increase in the bend angle.

At a bend angle of approximately 45­­o, the resistance of the flex sensor has increased to 65KΩ and when I continue to bend it at an angle of 900, the resistance further increases to 70KΩ. If I further bend it towards a complete 1800 angle, the resistance of the flex sensor shoots up to around 75KΩ.

NOTE: The resistance values mentioned here are specific to the Flex Sensor which I am using and they are not universal.

Flex Sensor Pin and Working Details

Types of Flex Sensors

Depending on the type of resistive material used on the surface of the Flex Sensor, there can be different types of Flex Sensors. Some of them are:

  • Carbon Resistive Flex Sensor
  • Capacitive Flex Sensor
  • Fiber optic Flex Sensor
  • Conductive ink Flex Sensor
HARDWARE REQUIREMENT
  • Arduino uno
  • Breadboard
  • Flex Sensor
  • Led
  • 10KOhm & 220 Ohm resistor

Ciruit Diagram

Code

const int ledPin = 3; //pin 3 has PWM funtion
const int flexPin = A0; //pin A0 to read analog input
int value; //save analog value
void setup(){
pinMode(ledPin, OUTPUT); //Set pin 3 as Output
Serial.begin(9600); //Begin serial communication
}
void loop(){
value = analogRead(flexPin); //Read and save analog value from potentiometer
Serial.println(value); //Print value
value = map(value, 700, 900, 0, 255);//Map value 0-1023 to 0-255 (PWM)
analogWrite(ledPin, value); //Send PWM value to led
delay(100); //Delay
}

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.