Overview
In this tutorial we will learn about flex sensor and its interfacing with Arduino. We will also learn how does a flex sensor works and also its applications.
A Flex Sensor or Bend Sensor is a device that measures the amount of bend or angular deflection by resistance change. A Flex Sensor is made up of a variable resistive surface. The sensor resistance is varied by bending the sensor. The resistance is directly proportional to the amount of bending. So it is sometimes called as Flexible Potentiometer. The real-life application of Flex sensor can be seen in the determination of joint movement & sometimes used as a door sensor and most powerful application in robotics to make Robotic Arm.
We will then go through few examples and learn the applications of flex sensor with Arduino. The examples include:
1. Interfacing of Flex Sensor with Arduino, i.e Calculating Resistance.
2. Calculating bend angle using Flex Sensor.
3. Controlling Servo Motor using Flex Sensor.
Bill of Materials
Following are the components required for making this project. All the components can be eaily purchased from Amazon. The components purchase link is given below.
S.N. | Components Name | Quantity | Purchase Links |
---|---|---|---|
1 | Arduino UNO Board | 1 | Amazon | AliExpress |
2 | Flex Sensor 2.2" or 4.5" | 1 | Amazon | AliExpress |
3 | Servo Motor SG90 | 1 | Amazon | AliExpress |
4 | Resistor 10K | 1 | Amazon | AliExpress |
5 | Resistor 330-ohm | 1 | Amazon | AliExpress |
6 | LED 5mm Any Color | 1 | Amazon | AliExpress |
7 | Connecting Jumper Wires | 5 | Amazon | AliExpress |
8 | Breadboard | 1 | Amazon | AliExpress |
Flex Sensor
Overview
A 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 the resistance of the sensor element is varied by bending the surface. Since the resistance is directly proportional to the amount of bend it is used as a goniometer, and often called a flexible potentiometer.
Flex sensors are available in two different sizes: one with 2.2″ (5.588cm) length and other with is 4.5″ (11.43cm) length. The width of the sensor is generally 0.6cm.
Construction of Flex Sensor
The flex Sensor construction diagram is given below.
A flex sensor is constructed by depositing conductive ink on a phenolic resin substrate. A segmented conductor is placed on the top section.
Handling Flex Sensor
Flex sensors are designed to bend in a single direction as shown in the figure below. Bending it in another direction may damage it.
Flex Sensor Working
An unflexed flex sensor, i.e a flat flex sensor has resistance around 25K to 30K. When the sensor is bent to 45 degrees the resistance increase and goes nearly 65K. Similarly, when it is bent to 90 degrees, the resistance becomes almost 100K. It is to note that, this value of resistance is not fixed and may change in your case.
Types of Flex Sensor
Depending on the type of resistive material used on the surface of the Flex Sensor, they are classified as:
1. Conductive ink-based flex sensor
2. Fiber optic flex sensor
3. Capacitive flex sensor
4. Velostat flex sensor (popular among hobbyists)
Basic Flex Sensor Circuit
As Flex sensor is a variable resistor, it can be read by connecting it with a fixed value resistor 10kΩ. This forms a voltage divider network. One end of the flex sensor is connected to GND while the other end is connected to Analog Input A0 of Arduino. A 10KΩ resistor is connected between A0 and +5V.
Interfacing Flex Sensor with Arduino
Now let us interface the Flex Sensor with Arduuino & calculate the raw value after bending.
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
const int flexPin = A0; void setup() { Serial.begin(9600); } void loop() { int flexValue; flexValue = analogRead(flexPin); Serial.print("sensor: "); Serial.println(flexValue); delay(20); } |
After uploading code, you can check the raw value of the flex sensor by bending it. The raw value changes on the basis of bending of the sensor.
Controlling Servo Motor with Flex Sensor & Arduino
Now let us control Servo Motor by bending the Flex Sensor with Arduino. The circuit diagram is given below.
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <Servo.h> Servo myServo; const int flexPin = A0; void setup() { myServo.attach(11); } void loop() { int flexValue; int servoPosition; flexValue = analogRead(flexPin); servoPosition = map(flexValue, 800, 900, 0, 180); servoPosition = constrain(servoPosition, 0, 180); myServo.write(servoPosition); delay(20); } |