Robotic arm servo twitching

Hello!

I'm building a robotic arm for a college project, it is powered by an Arduino Uno, and 3 servos with 15kgf of torque, the arm has been build with stainless steel and a 12v/1.5a font provides the power for all the structure. But I'm facing a problem when the arm try to grab an object, the base servo starts to twitch making impossible for the arm to grab the object, has can been seen on the video below:

And here's the arm code (I used the servo library):

#include "Ultrasonic.h"
#include <Servo.h>;
// Pino VCC -> 5V
// Pino GND -> GND
#define echoPin 13 // Pino 13 -> Echo
#define trigPin 12 // Pino 12 -> Trig
#define LED 8
Ultrasonic ultrasonic(trigPin,echoPin);
int parado = 0;
int inicio = 0;
Servo gservo;
Servo aservo;
Servo bservo;

void setup()
{
gservo.attach(11); //fio do servo da Garra
aservo.attach(9); //fio do servo da Articulação
bservo.attach(10); //fio do servo da Base
}

void mexendo(void) {
    aservo.write(110);
    delay(15);

    bservo.write(180);
    delay (1500);

    gservo.write(100); 
    delay(1500);
      
    aservo.write(100);
    delay(1500);
    
    aservo.write(90);
    delay(1500);
    
    aservo.write(75);
    delay(1500);
    
    aservo.write(60);
    delay(1500);
    
    aservo.write(45);
    delay(1500);
    
    aservo.write(30);
    delay(1500);
    
    aservo.write(10);
    delay(1500);
    
    aservo.write(5);
    delay(1500);
                                
    gservo.write(75); 
    delay(300);
         
    gservo.write(70); 
    delay(500);
    
    aservo.write(30);
    delay(1500);
    
    aservo.write(60);
    delay(1500);
    
    aservo.write(90);
    delay(1500);
    
    aservo.write(110);
    delay(1500);
    
    bservo.write(55);
    delay (3000);
    
    bservo.write(1);
    delay (3000);
         
    aservo.write(100);
    delay(1500);
    
    aservo.write(90);
    delay(1500);
    
    aservo.write(70);
    delay(1500);
    
    aservo.write(60);
    delay(1500);
     
    aservo.write(40);
    delay(1500);
    
    gservo.write(80); 
    delay(1500);
       
    bservo.write(55);
    delay(1500);
  
    aservo.write(90);
    delay(300);
    
    aservo.write(110);
    delay(1500);
      
    gservo.write(100); 
    delay(3000);
    
        
}

void quieto(void) {
    aservo.write(110);
    delay(1500);

    bservo.write(55);
    delay (1500);

    gservo.write(100); 
    delay(1500);
}

void loop(){
  int i=0;
  long distance=ultrasonic.Ranging(CM);
  while(i<4) {
   distance=(distance + ultrasonic.Ranging(CM))/2;
   i++; 
  }
    if(distance<10) {
     digitalWrite(LED,HIGH); 
     mexendo();
     inicio=1;
  } else {
    digitalWrite(LED,LOW);
    if(inicio==0) { 
      quieto();
      delay(1000);
      parado=1;
      }
    
  }
  
}

I've searched for the solution changing the code and the electronics, but I didn't find anything that could help me to resolve this issue, somebody could help me?

Servos are normally powered with 5-6v instead of 12v (which might damage the servos). Make sure the servo power supply and arduino grounds are connected together. Stainless steel is a heavy material to be using with a servo powered arm. Below is a typical servo power setup.

Hello zoomkat! Thanks for the reply!

I'm powering the servos with 7v, the 12v font voltage is reduced by an LM7809, that provides power for the arduino and an LM7807, that provides the power for the 3 servos.

Below is the draft of the electronic project:

tuliocpa:
I'm powering the servos with 7v, the 12v font voltage is reduced by an LM7809, that provides power for the arduino and an LM7807, that provides the power for the 3 servos.

7 volts is still too large for most servos; the vast majority of servos are designed to work on 4.8 - 6.0 volts - no more or less. There do exist servos that will operate on 7.2 and 9.6 volts (common battery voltages in the hobby R/C world), but they aren't a common item, and they also tend to cost a bit more.

Use an LM7806 instead.

Hello cr0sh! Thanks for the reply!

I've changed the LM7807 for the LM7806, but the problem persists...

Add some Serial.print debugging statements to make sure the code is doing what you expect.