I am building a robotic arm with 4 servos controlled independently by 4 potentiometers and it is an upgraded version of the same project I had already built before, the only change is an upgrade in the servomotors. I have tested all the material independently and it all works, and the code is the same I used in the previous project, so I think the problem might be in the delay part in the code because the new servos are a bit slow, here is the code:
#include <Servo.h>
//servo 1 settings
Servo servo1;
const int servo1PotPin =A0;
const int servo1Pin =3;
int servo1Value;
//servo 2 settings
Servo servo2;
const int servo2PotPin =A1;
const int servo2Pin =4;
int servo2Value;
//servo 3 settings
Servo servo3;
const int servo3PotPin =A2;
const int servo3Pin =5;
int servo3Value;
//servo 4 settings
Servo servo4;
const int servo4PotPin =A3;
const int servo4Pin =6;
int servo4Value;
void setup() {
servo1.attach(servo1Pin);
servo2.attach(servo2Pin);
servo3.attach(servo3Pin);
servo4.attach(servo4Pin);
}
void loop() {
servo1Value = analogRead(servo1PotPin);
servo1Value = map(servo1Value, 0, 1023, 0, 359);
servo1.write(servo1Value);
servo2Value = analogRead(servo2PotPin);
servo2Value = map(servo2Value, 0, 1023, 29, 94);
servo2.write(servo2Value);
servo3Value = analogRead(servo3PotPin);
servo3Value = map(servo3Value, 0, 1023, 0, 79);
servo3.write(servo3Value);
servo4Value = analogRead(servo4PotPin);
servo4Value = map(servo4Value, 0, 1023, 90, 179);
servo4.write(servo4Value);
delay (15);
}
The thing is when I increase the delay time the servos only move a slight bit every step but if I decrease it they start going slowly to random points, what is strange because both the servos and potentiometers work perfectly on their own, the circuit is also ok.
Does anyone know how I could fix it?