Problems with servo motor in robotic arm, It isn't controlling

Hi everyone:

I have a problem with my servo MG995, well It isn't controlling. I used a program to control a servo with a potenciometer, but this only turn in one direction until it reaches its top and while I turn potenciometer, this not makes none type of control and I don´t know why. Also the program that I'm using to control the servo is same for others servos and these servos of differents brands or types work right.

Well I'm using a switching source of 5 volts and 10 Ampers and I'm using an Arduino Uno, the pinout 3 as analog output to control for PWM. Also I want to add that I was using this servos in a robotic arm 3 months ago and these work right then I stopped using them for not too long time and now I have wanted prove these individually each one, but 3 of 5 servos have same problem.

Here is my code:

#include <Servo.h>
int Lecturas1[10];
int Val1, i = 0, Total1 = 0, Promedio1 = 0;
Servo MiServo1;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);  
MiServo1.attach(3);
for(i=0; i< 10; i++) 
Lecturas1[i] = 0;
i=0;
}

void loop() {
  // put your main code here, to run repeatedly:
Total1 = Total1-Lecturas1[i];
Lecturas1[i] = analogRead(A0);
Total1 = Total1 + Lecturas1[i];
i = i + 1;
if (i >= 10){
i = 0;
Promedio1 = Total1 / 10;
Val1 = map(Promedio1, 0, 1023, 0, 179);
MiServo1.write(Val1);
Serial.println(Val1);
}
}

but 3 of 5 servos have same problem.

Your code only has one servo instance. If changing the hardware that the software controls results in different behavior of the hardware, the software is NOT the problem.

Proper use of code tags on your first post. YAY! Karma++

I am not sure what you are doing in your code.
If you are trying to troubleshoot misbehaving servos, I would use a piece of code that has been proven to work.
The knob tutorial comes to mind.
https://www.arduino.cc/en/tutorial/knob

PaulS:
the software is NOT the problem.
https://www.arduino.cc/en/tutorial/knob

Yes, I think same the software isn't the problem, but I would like to know if you have a schematic of the electronic circuit components of inside of the servo because I think that the problem would be there in some component of the circuit. Also I will try to prove with another Arduino to discart options.

vinceherman:
Proper use of code tags on your first post. YAY! Karma++

I am not sure what you are doing in your code.
If you are trying to troubleshoot misbehaving servos, I would use a piece of code that has been proven to work.
The knob tutorial comes to mind.
https://www.arduino.cc/en/tutorial/knob

Thank you for look at this.
Well the program is a filter for the control of the servo, this average 10 values and show a result for that this will be more stable and remove vibrations and possible changes of possition of the servo.
Also I proved your program and I'm still having the same problem, the servo dosen't recives none type of control. And also I would like to know if you have a schematic of the electronic circuit components of inside of the servo because I think that the problem would be there in some component of the circuit.

You tried the knob tutorial and the servo did not behave as expected.
Did you try it with other servos and confirm that they DO work as expected?

There are 2 methods of failure that occur with some frequency
Stripped gears
Burned out motor/electronics from stalling a servo for a long period of time

If you order replacement servos, consider purchasing an extra servo or two for this possibility.