Muhammad Anas
Published © GPL3+

Control a Servo with a Force Resistive Sensor on Arduino

The force resistive sensor outputs the applied force to the Arduino, and we move the servo according to the amount of force.

BeginnerProtip1 hour24,111

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Force resistive sensor (FSR)
×1
Servos (Tower Pro MG996R)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino Web Editor
Arduino Web Editor

Story

Read more

Schematics

Circuit diagram

Code

Arduino code

C/C++
 #include <Servo.h>
 Servo servo;
 int reading;   
 
void setup(void) {
 Serial.begin(9600);   
 servo.attach(9); //servo at digital pin 9
 servo.write(0); //initial point for servo

}
 
void loop(void) {
  reading = analogRead(A0); //attached to analog 0
  Serial.print("Sensor value = ");
  Serial.println(reading);
 
int value = map(reading, 0, 1023, 0, 255);

  servo.write(value);
 
  delay(100);
}

Credits

Muhammad Anas

Muhammad Anas

6 projects • 38 followers
Thanks to Viscous.co 3D printing pakistan.

Comments