hello, for my project i am controlling 2 servos, for this I use an extarnal 6v power source. The servos are not really working vey well, at first I had to wrtie values like 93 to stop them from moving. Then suddenly one did not stop at all, I opened the servo but did not do anything, now it moves at full speed clockwise no matter what value I give. I think the circuit is right. negatives from the servos go to gnd together with batterie and positive with positive. also th signal cables are inserted into the arduino.
hello, for my project i am controlling 2 servos, for this I use an extarnal 6v power source. The servos are not really working vey well, at first I had to wrtie values like 93 to stop them from moving. Then suddenly one did not stop at all, I opened the servo but did not do anything, now it moves at full speed clockwise no matter what value I give. I think the circuit is right. negatives from the servos go to gnd together with batterie and positive with positive. also th signal cables are inserted into the arduino.
And it sounds like these are continuous rotation servos? I've never used one before...
It's looping really really fast thru that loop though, so I think you'll be confusing the servos by the frequency with which you send those writes (whether the servos are normal or continuous....)
Edit....
Afaik, once a servo is continuous, that's the way it's going to stay. On a normal servo the value you send is a position, but for a continuous one, that value is the rotation speed.
the other servo is working correctly, also with the buttons. another detail: I can only upload when the gnd is not plugged in, else it gives an error message
timmie:
any suggestions for the code then? I just want the motors to do nothing untill a button is pressed, should be possible right?
Servo test code that has writeMicroseconds which is better with continous rotation servos.
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7); //the pin for the servo control
Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
int n = readString.toInt(); //convert readString into a number
// auto select appropriate value, copied from someone elses code.
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
}
readString=""; //empty for next input
}
}