Shahir nasar
Published © GPL3+

Simple Homemade Flex Sensor

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

BeginnerProtip36 minutes13,748
Simple Homemade Flex Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
RobotGeek 180 Degree Robot Servo
RobotGeek 180 Degree Robot Servo
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

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 • 2 followers
Entrepreneur | Founder and CEO of Holse Products

Comments