I have got several models of Servos (MG996R, Hitec HS-422, and many more)
Servos attached to pins 6,9,10,11 work OK, any model.
Servos attached to pins 3,5 do not work, except curiously for model HS-422.
Power supply is not problem 5V, 30A. Besides I test little servos, very low amps, that work without problem in pins 6,9,10 11, but they refuse to move in pins 3,5.
If pins 3,5 never worked, maybe the problem would be more traceable, but they work only with hitec servos.
You are not defining the pins for analog inputs correctly .
Should be “int potpin1 = AO “ ; same for the others . So in your code , it happens by chance that “3” and “5” are used twice - but you intend one as digital 3 and the other as A3.
Exactly. It works now.
However, analog inputs were reading OK when mapping as 0-5. Maybe the problem was pinMode(x, INPUT) that declares as Digital Inputs 3 and 5, instead A3 and A5.
Thank You.
@liken perhaps this is just test code that was made quickly and you are aware it is not optimised, but... you really need to learn to use arrays. Your code is 6 times longer than it should be.
This article confirms that what @liken 's code was previously doing (using analogRead(0) rather than analogRead(A0)) does indeed work:
However, I could find nothing on any official Arduino page that describes it, so I feel it should be considered an "undocumented feature" and therefore using it should be strongly discouraged. Clearly it results in issues, as this topic demonstrates!
A0 has integer value 14 in Arduino Uno, Duemilanove,...
You can use 0,1,2,... for analogread() instead 14,15,16,... and it works.
But what you must not do is a pinmode(3,INPUT) affecting digital pin 3 you are using for another stuff. It must be pinmode (17,INPUT), or pinmode (A3,INPUT) to avoid errors.
About the mistery of HITEC servo working nonetheless, I think something in servo library is overwritten if you attach a servo on pin 3 and after you do a pinmode (3, INPUT). This causes most servos to stop working. However the hitec servo must have something different in its control loop that makes it tolerant.