Robotics EveryDay
Published © GPL3+

Interfacing Arduino With Flex Sensor and Servo Motor

Getting Started with flex sensor and connecting it with arduino. Actuating servo motor as per the bending of flex sensor.

BeginnerProtip12,429
Interfacing Arduino With Flex Sensor and Servo Motor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SparkFun Flex Sensor
×1
Resistor 163K Ω
Check the resistance of your flex sensor and then select the resistor.
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

flex_sensor_Lvb7wiwHcg.png

Code

Untitled file

Arduino
#include <Servo.h>

Servo m;

void setup()
{
  pinMode(13, OUTPUT);
  pinMode(A0,INPUT);
  m.attach(7);
  Serial.begin(9600);
}

void loop()
{
  float x=analogRead(A0);
  float y= ((x-159)/352);
  
  int angle=(y*180);
  Serial.println(angle);
  m.write(angle);
  
}

Credits

Robotics EveryDay

Robotics EveryDay

0 projects • 9 followers

Comments