Hello, I am trying to control 2 different projects (robotic arms) with multiple potentiometers that correlate to multiple servos. For example potentiometer 1 controls servo 1, and so on.
The problem I am encountering is that the servos will move wildly almost on their own.
Project 1 uses 4x servos, MG90s. This uses an Arduino Uno Rev 3
Project 2 uses 6x servos, 4x are HS-645MG, 1x is HS-225HG, and 1x HS-805BB. This uses an Arduino Uno Rev 3
For Project 1, I have tried using just the Arduino itself to power the servos as well as an external power supply. For the power coming from the Arduino, only 1 potentiometer is being turned at a time. When I hook up the external is when the arm behaves erratically. Yes there is a common ground attached.
I have been able to control a single potentiometer without issue (Project 5 in the starter kit as well as a 60Kg one)
Project 2 has to use the external power supply and behaves the same way as Project 1.
I have tried 2 variations of the code, both achieving the same results. Should I use something other than the Uno?
Thank you
#include <Servo.h>
Servo myServo0;
Servo myServo1;
Servo myServo2;
Servo myServo3;
Servo myServo4;
Servo myServo5;
int potPin0 = A0;
int potPin1 = A1;
int potPin2 = A2;
int potPin3 = A3;
int potPin4 = A4;
int potPin5 = A5;
int potVal0;
int potVal1;
int potVal2;
int potVal3;
int potVal4;
int potVal5;
void setup() {
myServo0.attach(3);
myServo1.attach(5);
myServo2.attach(6);
myServo3.attach(9);
myServo4.attach(10);
myServo5.attach(11);
}
void loop() {
potVal0 = analogRead(potPin0);
potVal0 = map(potVal0, 0, 1023, 0, 180);
myServo0.write(potVal0);
delay(15);
potVal1 = analogRead(potPin1);
potVal1 = map(potVal1, 0, 1023, 0, 180);
myServo1.write(potVal1);
delay(15);
potVal2 = analogRead(potPin2);
potVal2 = map(potVal2, 0, 1023, 0, 180);
myServo2.write(potVal2);
delay(15);
potVal3 = analogRead(potPin3);
potVal3 = map(potVal3, 0, 1023, 0, 180);
myServo3.write(potVal3);
delay(15);
potVal4 = analogRead(potPin4);
potVal4 = map(potVal4, 0, 1023, 0, 180);
myServo4.write(potVal4);
delay(15);
potVal5 = analogRead(potPin5);
potVal5 = map(potVal5, 0, 1023, 0, 180);
myServo5.write(potVal5);
delay(15);
}


