Help with Servo motors direction

Hi, this is a newbie question :~. I am making a small car that has 2 servo motors attached to wheels on either side. The problem is, when I test it out the two servos spin in opposite directions from each other. I figured this is because one is flipped over in relation to the other since its on the other side of the car. How do I fix it so that they will spin uniformly in the same direction? I have tried switching red and black wires on one of the servo motors but that doesn't seem to work since the board doesn't turn on then.

My board is set up like this:

Any help on which wires I need to change? Thanks.

1) servos need to be powered from an external power source to prevent arduino problems, and 2) post the code you are using.

First do what zk says and hook them up to an external power supply… running one off an Arduino is marginal, two is asking for something to “pop”. See attached pic…

Second, I’m assuming these are continuous servos, not normal servos, where the “position” value you send is actually the speed and direction? Make one of the speeds <90 and one >90 and they will go different directions. (90 is stop, then decreasing towards 0 increases speed one direction, increasing towards 180 increases speed the other direction. Stop might not be exactly 90, apparently: might have to experiment, maybe 89, maybe 91, who knows…)

EDIT… I just looked at your pic again and notice you have them on the same control wire. For my suggestion to work you’ll have to declare another servo on another pin, and control it separately.

HTH?

Jim

The code is standard Sweep program.

And thank Jimbo I will try that. :D

And I'm wondering what would happen if I run 2 servos without an external power supply? Will they get damaged?

And I’m wondering what would happen if I run 2 servos without an external power supply? Will they get damaged?

No… the Arduino will, because it will probably be called on to deliver more current than it should.

But wait a moment… if you’re using the standard sweep program, that will be reversing direction at the end of each traverse and be going from 0 to 180 to 0 all the time.

Are you using standard servos or servos modified for continuous rotation? It wouldn’t make sense to use standard servos for driving a robot, so presumably they are continuous? In which case, sweep will have the motors accelerating, decelerating, changing direction, accelerating in the new direction, decelerating etc etc.

Below is a basic concept of making two servos rotate in opposite directions. Bottom is some servo test code you can use to see the better continuous rotation servo control us using writeMicroseconds instead of an angle.

      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo1.write(n);
      myservo2.write(180-n);
// 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, 500, 2500);  //the pin for the servo control, and range if desired
  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
  } 
}