Arduino Nano Flex Sensor: Professional Bend Detection

Complete Arduino Nano flex sensor implementation with A0 analog reading, bend angle calculation, gesture recognition, servo control, LED bar graph, and serial plotting. Voltage divider with 10kΩ resistor, real-time flexion monitoring 0-90° range.

Arduino Nano Flex Sensor: Industrial Bend Controller

**Perfect flex sensor wiring confirmed!** A0 input, 10kΩ fixed resistor to 5V, other end to GND. Professional 2.2" 4.5kΩ-50kΩ flex sensor converts bend → 0-90° angle calculation, 5-LED bar graph (D3-D7), servo position control (D9), gesture detection.

**Bend finger → Serial shows angle + LED bar fills + servo moves**! Real-time monitoring 100Hz.

Production Flex Sensor Components

  • Arduino Nano
  • 2.2" Flex Sensor (4.5kΩ straight, 50kΩ bent)
  • 10kΩ resistor (voltage divider)
  • 5× LEDs + 220Ω resistors (D3-D7)
  • Servo motor (D9)
  • Breadboard + wires

Critical Voltage Divider Wiring

5V → 10kΩ resistor → Flex Sensor input → A0

Flex Sensor output → GND

Program: Professional Flex Sensor + Servo + LED Bar
// Arduino Nano FLEX SENSOR - INDUSTRIAL BEND CONTROLLER
// A0 + 10kΩ divider | Angle calc + Servo + 5-LED bar + Gestures

const int flexPin = A0;
const int servoPin = 9;
const int ledPins[] = {3,4,5,6,7};  // 5-LED bar
int straightVal, bentVal;

void setup() {
  Serial.begin(9600);
  
  // LED bar setup
  for(int i=0; i<5; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
  
  // Servo setup
  pinMode(servoPin, OUTPUT);
  
  // Auto-calibration
  calibrateFlex();
  
  Serial.println("=== FLEX SENSOR PROFESSIONAL CONTROLLER ===");
  Serial.println("Raw  Bend°  | LEDs | Servo | Gesture");
}

void loop() {
  int rawVal = analogRead(flexPin);
  float bendAngle = mapAngle(rawVal);
  int ledCount = map(bendAngle, 0, 90, 0, 5);
  int servoPos = map(bendAngle, 0, 90, 0, 180);
  
  // LED bar graph
  updateLedBar(ledCount);
  
  // Servo position
  servoWrite(servoPin, servoPos);
  
  // Gesture detection
  String gesture = detectGesture(bendAngle);
  
  // Live display
  Serial.printf("%4d %5.1f | %2d/5 | %3d° | %s\n", 
                rawVal, bendAngle, ledCount, servoPos, gesture.c_str());
  
  delay(10);  // 100Hz
}

void calibrateFlex() {
  Serial.println("CALIBRATE: Hold STRAIGHT 3s...");
  delay(3000);
  straightVal = analogRead(flexPin);
  
  Serial.println("CALIBRATE: Bend FULL 3s...");
  delay(3000);
  bentVal = analogRead(flexPin);
  
  Serial.printf("Straight: %d, Bent: %d (90° range)\n", straightVal, bentVal);
}

float mapAngle(int raw) {
  // Linear interpolation straight(0°) → bent(90°)
  if(straightVal == bentVal) return 0;
  return constrain(map(raw, straightVal, bentVal, 0, 90), 0, 90);
}

void updateLedBar(int count) {
  for(int i=0; i<5; i++) {
    digitalWrite(ledPins[i], i < count ? HIGH : LOW);
  }
}

void servoWrite(int pin, int pos) {
  // Simple servo pulse (50Hz)
  int pulse = map(pos, 0, 180, 1000, 2000);
  digitalWrite(pin, HIGH);
  delayMicroseconds(pulse);
  digitalWrite(pin, LOW);
  delay(20 - pulse/1000);  // 20ms period
}

String detectGesture(float angle) {
  if(angle < 10) return "STRAIGHT";
  if(angle < 30) return "SLIGHT";
  if(angle < 60) return "MEDIUM";
  if(angle > 80) return "FULL BEND";
  return "BENDING";
}

UPLOAD → AUTO-CALIBRATE + LIVE BEND TRACKING

**Straight → 0° + servo 0°**. **Full bend → 90° + servo 180° + 5 LEDs**!

Voltage Divider CRITICAL

5V —[10kΩ]— Flex —[Variable 4.5k-50kΩ]— GND

**A0 reads middle point** → 0.2V straight → 3V full bend → maps 0-90°

Flex Sensor Specs

  • 2.2" length, 0.45mm thick
  • 4.5kΩ straight → 50kΩ 90° bend
  • Repeat accuracy ±2%
  • Operating voltage 3.3-5V
  • Bend radius >15mm

Gesture-Controlled Robot Arm

Program: Wireless Gesture (nRF24L01)
// Add to loop() after angle calc
if(angle > 45) {
  // Send 'GRIP' command
  radio.write(&command, sizeof(command));
}

Prosthetic Finger Control

  • 5 fingers = 5 flex sensors
  • A0-A4 analog inputs
  • PCA9685 servo driver
  • Wireless EMG + flex

Calibration & Tuning

  • **Straight hold** → Sets 0° reference
  • **Full bend** → Sets 90° maximum
  • **Recalibrate** → Restart after mounting
  • **10kΩ optimal** → Match sensor resistance

Troubleshooting

  • Always 0°: 10kΩ missing/loose
  • Always 90°: Flex sensor damaged
  • Jerky servo: Add 100µF cap to servo
  • Non-linear: Recalibrate extremes