Shahir nasar
Published © GPL3+

Simple Homemade Flex Sensor

This project shows you how to make a homemade flex sensor.

BeginnerProtip36 minutes18,170
Simple Homemade Flex Sensor

Things used in this project

Story

Read more

Schematics

circuit diagram

Code

code for controlling servo with flex sensor

Arduino
#include <Servo.h>

Servo servo1;
const int flexpin = 0;

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



void loop ()
{
  int flexposition;
  int servoposition;
  flexposition = analogRead(flexpin);
  servoposition = map(flexposition, 1020, 1023, 0, 90);
  servoposition = constrain(servoposition, 0, 90);
  servo1.write(servoposition);
  Serial.print("sensor: ");
  Serial.print(flexposition);
  Serial.print(" servo:");
  Serial.println(servoposition);
  delay(1000);
}

Credits

Shahir nasar

Shahir nasar

0 projects • 4 followers
Entrepreneur | Founder and CEO of Holse Products

Comments