Can’t connect FSR and Servo

I’m trying to control my servo using force resistive sensor. But my servo does absolutely nothing. I tried many different wiring schemes but nothing helped. My sensor output is correct, but after some time it starts to look like this: sensor = 1E;
sensor = 1CE etc.
Maybe my servo has not enough energy?
My current wiring:


My code:

#include <Servo.h>

int sensor = 0;
Servo servo_7;

void setup() {
  pinMode(A0, INPUT);
  servo_7.attach(9, 500, 2500);
  Serial.begin(9600);
}

void loop() {
  sensor = analogRead(A0);
  Serial.print("sensor = ");
  Serial.println(sensor);

  if (sensor != 0) {
    Serial.println("ok");
    servo_7.write(180);
  } else {
    servo_7.write(0);
  }
  delay(1000);
}

Servos and motors cannot be powered from the Arduino 5V pin.

Use a separate power supply, and don't forget to connect the grounds.

Do you think your 'sensor' value will ever get '0'? I don't think so. That means your servo always get the command to move to 180 and will never move elswhere.
And what servo are you using? servo.write(180) will create a pulse of 2.5ms in your case. Many digital servos will ignore this completely, because it is out of their specs.

What values do you read?

I added power supply, but still nothing

I changed with to “sensor >= 600”, but this didn’t worked as well.

Now this all looks like this.


Is that a 4 AA battery pack?

Yes, 1,5 x 4 = 6W. I thought this would be enough for servo. Am I wrong?

No it's perfect.
I would try the servo sweep example to test that the servo works.

If the battery pack struggles to start the servo, add a 100uF electrolytic capacitor across VCC and GND at the servo. This will help stabilize the supplied power as the servo starts moving, when power load is greatest.

If that is true then you need new batterties.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.