Flex Sensor

Z2M Part: EDT-00007-A

Measure bend or flex using a flex sensor.

Circuit Diagram
Circuit diagram for Flex Sensor
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow → A0 to flex–resistor junction, Pin 7 to LED
Red → 5V to flex sensor
Black → GND to 10kΩ, LED cathode

Pin Configuration:

Arduino Analog Pin A0 → Flex sensor (voltage divider junction)
Arduino 5V → Flex sensor (one leg)
Arduino GND → 10kΩ resistor (voltage divider)
Arduino Digital Pin 7 → LED anode (via 220Ω resistor)
Arduino GND → LED cathode
Arduino Code
Edit
#define led_Pin 7   // LED connected to pin 7
#define sensor A0   // Flex sensor connected to A0

int analog_value;   // Variable to store analog reading
int angle_value;    // Variable to store calculated angle

void setup() {
  pinMode(led_Pin, OUTPUT);  // Set LED pin as output
  Serial.begin(9600);        // Initialize Serial Monitor
}

void loop() {
  // Read analog value from flex sensor
  analog_value = analogRead(sensor);

  // Map analog value range (700–900) to angle range (0–180)
  angle_value = map(analog_value, 700, 900, 0, 180);

  // Print readings to Serial Monitor
  Serial.print(\"Analog: \");
  Serial.println(analog_value);
  Serial.print(\"Angle: \");
  Serial.println(angle_value);

  // Turn on LED if flex angle > 90°, else turn off
  if (angle_value > 90) {
    digitalWrite(led_Pin, HIGH);
  } else {
    digitalWrite(led_Pin, LOW);
  }

  delay(1000); // Wait 1 second before next reading
}

Instruction Details

Wiring: Connect flex sensor one end to 5V, other end to 10kΩ resistor to GND. Connect junction to Analog Pin A0. Connect LED anode to Digital Pin 7 via 220Ω, cathode to GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor at 9600 baud for analog and angle values. LED turns ON when bend angle exceeds 90°.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • Flex Sensor
  • 10kΩ Resistor (voltage divider)
  • LED
  • 220Ω Resistor
  • Breadboard
  • Jumper Wires

Category: Sensors