กลับไปหน้ารวมไฟล์
interfacing-arduino-with-flex-sensor-and-servo-motor-2cd595-en.md

Connecting Flex Sensor With Arduino and Servo Motor

For Detailed Explanation Watch This Video

About Flex Sensor

Flex sensor is a flexible resistor, it 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

Flex Sensor

Measurement of Sensor Resistance

Connect the flex sensor to a multimeter, and set the multimeter on resistance.

Flex Sensor Connected With Multimeter

Note down its resistance when normal i.e. Straight ( bend angle = 0°)

Straight Resistance Measurement

Note down its resistance when fully bend ( bend angle = 180°)

Bend Resistance Measurement

Now, its time to connect it with arduino board.

Connecting Flex Sensor With Arduino

Connecting With Arduino

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.

Connecting Servo Motor

Connections with Servo Motor

Servo motor has three pins Power, Ground and Signal power and ground needs to be connected to 5V and GND pins of board respectively. Signal can be connected to any of the digital pin.

Record the analog input value by bending the sensor from minimum to maximum.

The servo motor need angle in degrees from to 180°, but the sensor data can be any value from 0 to 1024.

Use to the below code to convert the flex sensor value to proportional servo motor angle.

int const min_flex_val= 159 // analog input value for straight sensor
int const max_flex_val= 511 // analog input value for totally bended sensor
float flex_value = analogRead(A0);
float y= ((flex_value - min_flex_val)/(max_flex_val-min_flex_val));
int angle=(y*180); //angle value will be in the range 0 to 180

By doing above your motor should rotate proportionally to the bending of the sensor.

This can be used to control the hand of a robot, or mimic human hand gestures.

EXPANDED TECHNICAL DETAILS

Bio-Mechanical Kinesthetic Interface

This project mimics the movement of a human finger or limb by mapping the physical bending of a flex sensor to the angular position of a servo motor.

  • Resistive Voltage-Divider Acquisition: The flex sensor's resistance changes as it bends. The Arduino captures this via a 10-bit ADC, mapping the 0-5V analog signal into a discrete "Bend Factor."
  • Proportional Actuator Mapping: The firmware uses the map() function to translate the sensor's raw range (typically 20k - 100k ohms) into a 0-180 degree servo sweep.

Accuracy

  • ADC Noise Averaging: Includes a software "Running Average" filter. By averaging the last 5 readings, the Arduino prevents the servo from "Jittering" due to the electrical noise inherent in resistive sensors.

ข้อมูล Frontmatter ดั้งเดิม

title: "Interfacing Arduino With Flex Sensor and Servo Motor"
description: "Getting Started with flex sensor and connecting it with arduino. Actuating servo motor as per the bending of flex sensor."
author: "RoboticsEveryDay"
category: ""
tags:
  - "tinkercad simulations"
  - "flex sensor"
  - "servo motor"
views: 12107
likes: 1
price: 1499
difficulty: "Easy"
components:
  - "1x Jumper wires (generic)"
  - "1x Flex Sensor"
  - "1x Arduino UNO"
  - "1x Resistor 163K Ω"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "515bc8e095bf9ae592d939b08dac8daf7bfb79001f6db4a0684ef2a52c54181b"
encryptedPayload: "U2FsdGVkX1/k184nQY+MXqh4S+rxoiPBmGn4tJYCacvhTkj2+sXiILROUzYadaXgqdD5lyO76ztu+JWtwt3pFtahnk1PqHF8+GzQtsUUtMY="
seoDescription: "Interface a Flex Sensor with Arduino to control a Servo Motor based on bending. Ideal for robotics and wearable DIY projects."
videoLinks:
  - "https://www.youtube.com/embed/OZwxh_u1geE"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/interfacing-arduino-with-flex-sensor-and-servo-motor-2cd595_cover.jpg"
lang: "en"