Flex sensor is a sensing component that can measure or sense how much an object it attached to is bent.This tutorial covers interfacing of Flex sensor with Arduino.You will find interfacing diagram of this with Arduino and sample code with explanation.
FLEX SENSOR:
Flex sensor as the name suggests can be used to sense bending or measuring the flexible nature of any object.It works by exhibiting change in resistance when it is bent.Basically it is like a variable resistor in which the resistance change with the amount of bending or flexing the sensor has undergone.When the force is applied to the sensor bends and resistance varies.The bending or the angle of the deviation due to bending can be calculated based on change in the resistance.
WHY FLEX SENSOR IS USED:
These type of sensors are used mostly in robotics.Here the flex sensors are used to measure the angle of deviation caused due to the movement of robot.Moreover it is widely used in hand gesture applications.
FLEX SENSOR COMPOSITION:
Flex sensors are made up of carbon fiber, that enables it to gain the property to detect the angle of deviation.The outside material is made up of plastic while inner material is of carbon fiber.It gives the resistive property to Flex sensor so that resistance varies with change in sensor flexibility.
SPECIFICATIONS:
- Operating Voltage is 0 – 5V.
- Power rating is about 0.5 Watt to 1 Watt.
- Operating Temperature ranges from – 45 to +80 degree centigrade.
- The bend resistance ranges from 45K to 125K ohms.
PIN CONFIGURATION:
Above you can see the physical structure of flex sensor.It is a two terminal device with terminals P1 and P2 with a variable resistive property.A voltage divider should be built using this along with a Resistor in series to it.The Arduino can measure the variable analog voltage which develops due to bending.This gives the amount of deviation in the form of change in voltage.
CIRCUIT DIAGRAM:
CODE:
const int ledPin = 3!//pin 3 has PWM funtion const int flexPin = A0!//pin A0 to read analog input //Variables: 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)!//Small delay }
WORKING:
- The sensor works by varying resistance due to the change in flexibility or bending.
- Initially we read the analog value from sensor using value = analogRead(flexPin);
- Now the analog values are mapped to PWM values
- Value=map(value, 700, 900, 0, 255);
- Now value is sent to the LED and based on the value of PWM.This means when there is a bend in sensor, the LED turns on by turning its terminal to HIGH with code.
- In this way, the sensor works based on the change in the resistance that is detected by the microcontroller and the necessary actions can be performed based on that.
APPLICATIONS:
- Virtual Reality Gaming
- Robotics
- Music Instruments
- Physical Therapy
- Medical Equipment
Hope this tutorial was informative to you.You can check out our other188金宝搏下载 iosArduino tutorials here.If you have any queries leave them in the comment box below, we will answer them.Happy DIY