Servo motor issues when serial commands are used

Hi everyone, I am working on a project that uses 2 servo motors and a stepper motor . I am using serial commands to print to the monitor for debugging and everything was working fine until I tried to use a servo motor that came with an Arduino starter kit .

When running the sample Arduino servo code (sweep.ino) the motor runs fine, but as soon as I add "Serial.begin(9600);" into the code (in the setup area) the servo becomes unresponsive, the other 2 servo motors not included in the starter kit run fine with the added code.

So my questions are, is there any way to fix is issue of serial data transmission interfering with the motor? Is there a way that I can print debugging information besides using Serial commands? Should I just suck it up and buy another motor that I know works with Serial commands in the code (they are only 10 bucks + shipping)?

Thanks in advance for any advice.

Hi burgermiester (isn't that misspelled ?), welcome.

So you have 3 servos in total, and only one of them has this problem ? Do you connect all servos to the same pin, or are each of them connected to their own pins ? How are you powering the servos and how are you powering the Arduino ?

“burgermeister” was taken >:( so I switched up the letters.

Yes, I have 3 servos all connected to different pins. I forgot to mention in my original post that I have this motor controller which all 3 servos and the stepper motor are connected. Power is coming to the Arduino board from a usb port on my computer, the servo motors are powered by 5v pins on the motor controller, and the stepper motor is powered from a 12v power supply.

You need to post the program that illustrates your problem. I can't imagine how Serial.begin() would, on its own, have any effect on the sweep example.

...R

Here is the sweep code that I have been running with two changes.

  1. I changed the max sweep to 90 from 180 because the servo in question is currently in a position where it can only turn 90 degrees (if it might be causing an issue I can take some stuff apart and get the motor to turn the full 180 of the default sweep).

  2. I added Serial.begin(9600); in the setup function, if I comment this line out the servo runs perfectly. When I try the code with the Serial call running the servo will move to 45ish degrees, then back to 0 and just sit there. Its kinda bizarre…

Also one more thing to note, I have tried the same code with the servo on pins 0,1,3,8 with no success. If I attach one of the other servos I purchased (referenced in the first post) it works regardless of the Serial.begin line or pin number.

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(1);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop() {
  for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 90; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}
  myservo.attach(1);  // attaches the servo on pin 9 to the servo object

Pin 1 is the serial TX.

Don’t use pins 0 or 1 for anything because they are used by Serial.

For testing try to get the servo to move between (say) 30 and 150 degrees. Most servos should manage that range. Not all of them will go to to0 or 180. If it works between 30 and 150 you can extend that range a bit at a time to find the limits for that particular servo.

If one servo will NOT move in the range 30 to 150 and the others will then I would suspect a faulty servo.

…R

Mark T and Robin2, that solves it! When I was testing the different pins I always had something on pin 1, I was using the stepper controller that covers up the whole Arduino board and I couldn't see the markings for TX on pin 1, the controller has labels for the pins but didn't specify TX and RX on pins 1 and 0.

Thanks to everyone for trying to help out and sorry it ended up being an issue with the user....

Also one more thing to note, I have tried the same code with the servo on pins 0,1,3,8 with no success. If I attach one of the other servos I purchased (referenced in the first post) it works regardless of the Serial.begin line or pin number.

Really?