Animatronic mouth servo issue

Hello,
I am new to to the forum and working with arduino. I was hoping I can get some help on an issue that I am trying to figure out. I built an animatronic for my classroom using an arduino uno and two radio shack micro servos (Catalog #: 2730765). The original code works fine.

#include <Servo.h>
Servo mouthServo;
Servo tailServo;


void setup() {
  // put your setup code here, to run once:

  mouthServo.attach(10);
  tailServo.attach(9);
  
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:


  for(int j = 0; j < 3; j++){
    mouthServo.write(10);
    delay(1000);
    mouthServo.write(80);


    for(int i = 0; i < 7; i++){
      tailServo.write(60);
      delay(150);
      tailServo.write(120);
      delay(150);
    } 
  }

  mouthServo.write(10);

  // 45 minute delay 45*60*1000 = 2,700,000
  //2 minute delay 2*60*1000=120,000
  delay(120000);

}

The problem is any time I try to do anything else with mouth such as an adaption of the sweep program.

#include <Servo.h>
Servo mouthServo;
Servo tailServo;
int pos = 10;

void setup() {
  // put your setup code here, to run once:

  mouthServo.attach(10);
  tailServo.attach(9);
  
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

for (pos = 10; pos <= 80; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    mouthServo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 80; pos >= 10; pos -= 1) { // goes from 180 degrees to 0 degrees
    mouthServo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }

}

The servo can barely move at all. I have tried two different setup on the bread board and neither one seems to work. Any ideas why this issue is happening and how I can fix this?

Thank you,

Hi,

Try
int pos;

not

int pos=10;

I know pos +=1 should work, but try pos++ like in your first sketch.

Tom… :slight_smile:
Also check that you have a continuous red and blue/black line down the side buss on your protoboard, not a break the means a break in the buss.
Protoboards.jpg

I’d set it up here but its after midnight and believe me I need my beauty sleep.

Thanks Tom, I checked the board and it does have a continuous line. I also tested the two suggestions you gave me. Neither one fixed the board. While I was working on it, I did learn one thing. The tail servo can work on it's own the mouth servo does not work on it's own, but if the tail servo and mouth servo are moved at the same time, it will work. This code does work as intended.

void loop() {
  // put your main code here, to run repeatedly:

mouthServo.write(80);
tailServo.write(80);
delay(500);
mouthServo.write(40);
tailServo.write(100);
delay(500);

}

If I take out the tail segment tailServo it will no longer work and you will here the servo struggle to move. What would cause that too happen?

Hi, Have you tried swapping the servos? Only having one servo plugged in when you test each servo?

Have you tried a separate power supply for the servos? It sounds strange that two will work together, but one on its own will not.

Can you post a picture of your project so we can see your layout?

Thanks.. Tom.. :)

Thanks for the suggestion. When I swapped the servos it was the servo that wasn't working right. Now I know I can get it replaced.

Check your power supply is adequate and that neither servo is blocked from moving by the mechanism - a stalled servo will heat up and cook itself quite quickly. Even small servos need 1A or so each typically, and its a hugely common mistake to underprovide the power for them.

MarkT: Check your power supply is adequate and that neither servo is blocked from moving by the mechanism - a stalled servo will heat up and cook itself quite quickly. Even small servos need 1A or so each typically, and its a hugely common mistake to underprovide the power for them.

I was about to suggest the same, a separate supply for the servos.. My general rule of thumb, 2 or more servos, NEVER power them from the on-board +5V regulator, ALWAYS add a 2ndary +5V circuit, a LM7805 regulator between the main supply (wired in parallel with the +9V power supply before the barrel socket, NEVER from the Vin pin) & the Arduino, to a supply rail for the servos...