//Include Servo library
#include
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(6); // attaches the servo on pin 6 to the servo object
// Configure flex sensor pin
pinMode(A0, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
int flexSensor = analogRead(A0);
/*Values from sensor are about 380 -> 550;
we need to convert this to about 0 -> 170
since my finger is too short to be affected
when the servo moves 180 degrees*/
int angle = (flexSensor - 380) / 1;
Serial.println(angle);
myservo.write(angle); // set servo position
}