-1
\$\begingroup\$

This question already has an answer here:

as part of this old thread, I started trying using an old RC servo with arduino.

The one I used (Sanwa SRM 102) has a torque of about 3kg\cm and operates with 5V. I used an external power supply for the servo and made the wiring with the little material I found out on the web. The wires are RED-BLACK-BLACK and it seem to be +-\Signal.

This is the scheme:

enter image description here The problem appears when I try to upload my sketch. The servo tries to push as much as possible forward, forcing and I need to power off it.

Using the "Servo" library, the problem appears whatever I write in the myservo.write(x) statement, and tries to reach always the same position.

I made a little video to show you what I mean:

https://www.youtube.com/watch?v=lDvquFk9CZE

Maybe being and old servo it uses some different communication protocol?

What can I try?

This is my semplified sketch:

#include <Servo.h>
#define SERVO_PIN 9

Servo myservo;



void setup()
{
  myservo.attach(SERVO_PIN);

}

void loop()
{

 myservo.write(0);
 delay(5000);
 myservo.write(30);
  delay(5000);
  myservo.write(50);
  delay(5000);
  myservo.write(90);

}

EDIT: As suggested, it was just a problem of common gnd.

\$\endgroup\$

marked as duplicate by Chris Stratton, Bence Kaulics, PeterJ, Dave Tweed Sep 4 '16 at 11:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ have you connected the ground of arduino with ground of battery? \$\endgroup\$ – abhiarora Sep 3 '16 at 11:05
  • \$\begingroup\$ It would probably help if you connect the servo power with the same polarity as the battery power. \$\endgroup\$ – Dave Tweed Sep 4 '16 at 11:54
  • \$\begingroup\$ that was an error with the scheme, it was obviously connected correctly, otherwise it woudn't have moved. \$\endgroup\$ – lateralus Sep 5 '16 at 7:25
1
\$\begingroup\$

The program looks fine to me. However, i am not able to see any connection connecting Ground of battery with ground of arduino.

It is very important as there are two different circuits (one is your arduino and other is your servo connected with battery) in your project communicating with a single wire which delivers signal in pulse width modulation form(servo signal). The circuits should agree on same voltage reference which can be achieved by connecting ground of two circuits together.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.