3.interfacing of A Flex Sensor
3.interfacing of A Flex Sensor
To interface a flex sensor to the Arduino Uno and measure the bend angle
Theory:
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.
Flex sensor t has two pins. Whenever you bend it, its resistance changes. Its resistance
is minimum when it is relaxed or straight. And resistance is found maximum when bended.
It follows resistivity
ρ = RA/l
where ρ = resistivity of a material
R = Resistance
A = Area of the material
l = Length of the material
As the flex sensor is a variable resistor, we cannot connect it directly to arduino. We need a
voltage divider circuit. The first resistor will be fixed one. The value of the resistor must be
equal to the max resistance value of flex sensor. The fixed value resistor and flex sensor must
be connected in series. The fixed value resistor must be connected to 5V whereas the flex
sensor must be connected to GND. Their junction must be connected to pin A0 of the board.
Output:
Code:
int flexsensor = A0;
int ledPin = 3; // LED connected to pin 3
void setup()
{
Serial.begin(9600);
pinMode(flexsensor, INPUT);
}
void loop()
{
int sensorValue = analogRead(flexsensor);
int bendDegrees;
delay(20);
}
Screenshots:
Post-Lab questions:
1. Write an Arduino code to convert the flex sensor value to proportional servo motor
angle.
2. List out the specifications of any flex sensor.