Servos not moving correct degrees

Servos not moving correct degrees
Hi there. Completely new to Arduino and this forum, so sorry if this post is unappropriated. That also means I am probably going to give some very, VERY, simplistic answers, if you need more information

You mean, you tell the servo to move for example from 0 to 10 degree and it makes an angle of 12 degree?

Yes, that's normal. A servo is no precision device and every servo reacts differently. You can calibrate it a bit but don't expect miracles.

So what's the question?

(Along with code and circuit schematic)

Sorry, for some reason I can't seem to post my whole message. Anywas:
I managed to put together a funny little leave me alone box (see DON'T WAKE ME !!! - THE ORIGINAL by Sally71 (my shop: www.sally71.com, NO AMAZON !!!) - YouTube for an example, mine is however nowhere as well polished) and it works all right. But when it has run a few times the servos no longer reach the programmed angles, it’s like they decrease 1 or 2 degrees. As I am writing this, I wonder if it because I only use 4 AA batteries to power a total of 3 servos (2 very small ones, and one larger) and it simply “runs out of juice”?
Any help will be appreciated.

Aww that's bad news septillion... so there is no regularity to these discrepancies? Only asking as I wrote it seems to be acceptable variations on full battery, but as it drains they become more obvious.

Here is my very poorly written/Frankensteined code (It has 10 moves, but I have just left one in to shorten it a bit for you guys). Will try to make circuit schematics.

#include <Servo.h> 
Servo doorServo;
Servo handServo;

int switch_pin = 2;               //set switch on pin 2

//motor variables
int motorThrottle=11;
int motorDirection = 13;
int motorBrake=8;

//Distance Variables
int motionPin = 0;    //motion sensor pin on analog 0
int lastDist = 0;      //to remember last distance
int currentDist = 0;   
int thresh = 100;      //Threshold for Movement


int pos = 0;
int selectedMove = 0;             //move selector
int Testmove = 0;                 //test mode: set to move number to test only one selected move 
                                  //(set to Zero to run normally i.e: roundrobbin on amm moves)



void setup()
{
  Serial.begin(9600);
  pinMode(switch_pin, INPUT);
  doorServo.attach(9);           //set door servo on Pin 9 pwm
  handServo.attach(10);          //set hand servo on Pin 10 pwm
  doorServo.write(80);           //set door to hiding position 
  handServo.write(170 );            //set hand to hiding position
  //Setup Channel B, since Channel A is reserved by door and hand servos and can't ber used at same time
  pinMode(motorDirection, OUTPUT); //Initiates Motor Channel B pin
  pinMode(motorBrake, OUTPUT); //Initiates Brake Channel B pin
  
}


void loop()
{
if (Testmove != 0) {
selectedMove = Testmove;
}
  
  //if the switch is on, then move door and hand to switch it off...
  if(digitalRead(switch_pin) == HIGH)
  {
    
  if (selectedMove > 10) { selectedMove = 0; } //when all moves are played, repeat the moves from beginning 
  
  if (selectedMove == 0) { switchoff(); }
  else if (selectedMove == 1) { switchoff(); }   
  else if (selectedMove == 2) { switchoffbitaraddod(); }
  else if (selectedMove == 3) { crazydoor(); }
  else if (selectedMove == 4) { crazyslow(); }
  else if (selectedMove == 5) { m7anika7anika(); }
  else if (selectedMove == 6) { m3alla2(); }
  else if (selectedMove == 7) { switchoff(); }
  else if (selectedMove == 8) { matrix(); }
  else if (selectedMove == 9) { sneak(); }
  else if (selectedMove == 10) { zee7(); }
   
  if (Testmove == 0) {
  selectedMove++;         //swith to next move if not in test mode
  }

}
}



// Library of moves

   // Almindelig
   void switchoff() 
  {   
     delay(150);  
   //Moving door
    for(pos = 80; pos < 155; pos += 3)   
    {                                   
    doorServo.write(pos);              
    delay(22);                       
    }
   
    //Moving hand
    for(pos = 170; pos > 3; pos -= 4)  
    {                                   
    handServo.write(pos);               
    delay(22);                       
    }  
    
    //hiding hand
    for(pos = 3; pos<=170; pos+=4)      
    {                                
    handServo.write(pos);               
    delay(30);                        
    } 
      
    //hiding door
    for(pos = 155; pos>=80; pos-=3)     
    {                                
    doorServo.write(pos);              
    delay(22);                      
    } 
   }

Ahh, yeah, and a dropping battery voltage doesn't help for the accuracy :wink:

Oh well. So what I am hearing you say is something like "live with it, but you could try to add more power"?

By the way, here is a quick and lousy sketch

There are servos and servos - a high spec robotics servo will be better engineered than a standard
budget servo. Particular modesl and brands may be much better than others.

Remember what servos are designed to do - move an aileron or tail flap on a RC plane - thats all they
have to be able to do to be a viable hobby servo product. Want more, you pay for it!

According to your pic, all is ok in theory.

But if you have narrowed it down to being a problem when the batteries are going flat, well you need better mAh batteries and or to charge or replace them more often.

Or have more battery packs: say one or the big servo and one for the smaller ones.

Hi,
OPs pic.


Have you got that slide switch wired correctly
Tom.. :slight_smile:

Thanks for the quick answers.
Fair enough with the get-what-you-pay for principle regarding servos, would be disappointed if otherwise.
I'm thinking about using a battery pack like the ones in RC cars and such to get the mAh and keep it somewhat compact.
TomGeorge, thanks for the pic :wink: And yeah, the switch might be wired wrong in the picture - never post when tired...

a single servo will take anywhere from 4.8-6v.. but check your specific servo specs to be sure.

That being said.. again, a single servo can pull upwards of 1AMP EACH!.. especially while under load.

You have 3 servos. I dont think you have a beefy enough power supply.

Try using stable benchtop power supply see if the reliability stays..