فن
خوبصورتی اور تندرستی
دستکاری
ثقافت اور تاریخ
تفریح
ماحول
خوراک اور مشروبات
سبز مستقبل
ریورس انجینئرنگ
سائنسز
کھیل
ٹیکنالوجی
پہننے والے آلات
Using a Flex Sensor — SIK Circuit 9
Ed

تخلیق کار

Ed

17. March 2026

Using a Flex Sensor — SIK Circuit 9

Use a flex sensor to control a servo motor. Bend the sensor to move the servo — combining analog input with motor control for gesture-based interaction.

ہدایات

1

Parts & Introduction

A flex sensor changes resistance when bent. Combined with the servo from Circuit 8, you can create gesture-based controls — bend the sensor to move the servo. This combines analogRead() with the Servo library.

Parts Needed

  • 1x Arduino Uno + USB cable
  • 1x Breadboard
  • 1x Flex Sensor
  • 1x Servo Motor
  • 1x 10KΩ Resistor
  • 11x Jumper Wires
2

Hardware Hookup

Wiring Instructions

Flex Sensor
  1. Connect one pin of the flex sensor to 5V.
  2. Connect the other pin to Analog Pin A0.
  3. Connect a 10K resistor from Analog Pin A0 to GND (voltage divider).
Servo
  1. Connect Red wire to 5V.
  2. Connect Black wire to GND.
  3. Connect White wire to Digital Pin 9.
3

Arduino Code

Open the Arduino IDE and upload the following sketch to your Arduino board.

flex_sensor.inoarduino
/*
SparkFun Inventor's Kit
Example sketch 09 — FLEX SENSOR

Use the flex sensor to change the position of a servo.

Hardware connections:
  Flex sensor: one pin to analog pin 0 (with 10K to GND), other pin to 5V
  Servo: RED to 5V, WHITE to pin 9, BLACK to GND

This code is completely free for any use.
*/

#include <Servo.h>

Servo servo1;

const int flexpin = 0;

void setup()
{
  Serial.begin(9600);
  servo1.attach(9);
}

void loop()
{
  int flexposition;
  int servoposition;

  flexposition = analogRead(flexpin);

  servoposition = map(flexposition, 600, 900, 0, 180);
  servoposition = constrain(servoposition, 0, 180);

  servo1.write(servoposition);

  Serial.print("sensor: ");
  Serial.print(flexposition);
  Serial.print("  servo: ");
  Serial.println(servoposition);

  delay(20);
}
4

Test & Experiment

What You Should See

The servo moves in response to bending the flex sensor. Open the Serial Monitor to see both the raw sensor value and the mapped servo position.

Troubleshooting

  • Servo not moving: Check servo wiring — easy to plug in backwards.
  • Sensor only works one way: The flex sensor bends in one direction. The striped side should face outward on a convex curve.
  • Limited range: Adjust the map() range values (600, 900) to match your sensor's actual readings from the Serial Monitor.

Experiments to Try

  • Build a "robot finger" that mimics your finger bending.
  • Replace the servo with an LED and control brightness by bending.

مواد

  • SparkFun Inventor's Kit - V3.2 - 1 kitNOK 999.20
    دیکھیں
  • Arduino Uno R3 - 1 pieceپلیس ہولڈر
    دیکھیں
  • Breadboard - 1 pieceپلیس ہولڈر
    دیکھیں
  • Flex Sensor - 1 pieceپلیس ہولڈر
    دیکھیں
  • Servo Motor - 1 pieceپلیس ہولڈر
    دیکھیں
  • 10K Ohm Resistor - 1 pieceNOK 24.00
    دیکھیں
  • Jumper Wires - 11 piecessNOK 39.20
    دیکھیں

درکار اوزار

  • Computer with Arduino IDE

CC0 پبلک ڈومین

یہ بلیو پرنٹ CC0 کے تحت جاری کیا گیا ہے۔ آپ اجازت لیے بغیر اس کام کو نقل، ترمیم، تقسیم اور کسی بھی مقصد کے لیے استعمال کرنے کے لیے آزاد ہیں۔

میکر کی حمایت کریں ان کے بلیو پرنٹ کے ذریعے پروڈکٹس خرید کر جہاں وہ میکر کمیشن وینڈرز کی طرف سے مقرر، کماتے ہیں، یا اس بلیو پرنٹ کی نئی تکرار بنائیں اور آمدنی شیئر کرنے کے لیے اسے اپنے بلیو پرنٹ میں کنکشن کے طور پر شامل کریں۔

بحث

(0)

لاگ ان بحث میں شامل ہونے کے لیے

تبصرے لوڈ ہو رہے ہیں...