Problems controlling two modified MG996 servos along 3 other servos

I replaced the potentiometer with two 2200Ω resistors, I've tested each one individually and they work, the problem is when I add the rest of the servo, what happens is that servo1 does not respond properly and independently of what value I write it just keeps spinning clockwise at apparently the same speed.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>


RF24 radio(6,7); // CE, CSN
const byte address[6] = "00001";

int msg;
int val1;
int val2;
int val3;
int val4;
int val5;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;

void setup() {
  Serial.begin(9600);
  servo1.attach(1);
  servo2.attach(2);
  servo3.attach(3);
  servo4.attach(4);
  servo5.attach(5);

  servo2.write(85);//These are the modified servos, and with these values they are supposed to stop rotating, atleast they did stop when tested individually
  servo1.write(97);


  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  
  }

void loop() {

//What I do is send a variable of 4 digits, the first indicates the servo and the remaining the degrees to rotate
  
  if (radio.available()) {
  radio.read(&msg, sizeof(msg));
  if (msg/1000==1){
    val1= msg-1000;
    //servo1.write(val1);
  }else if (msg/1000==2){
    val2=msg-2000;
    //servo2.write(msg-2000);
  }else if (msg/1000==3){
    val3=msg-3000;
    servo3.write(msg-3000);
  }else if(msg/1000==4){
    val4-msg-4000;
    servo4.write(msg-4000);
  }else if (msg/1000==5){
    val5=msg-5000;
    servo5.write(val5);
  }
  Serial.println(msg);
} 
}

My only concern with the wiring is the way the connections to the GND and 5V, I attach a pic of what one of these connections looks like, the signal just goes directly to the pin it is assigned to.

servo1 does not respond properly

 Serial.begin(9600);
  servo1.attach(1);

Pin 1 is the Serial TX pin on most Arduino boards. Which board do you have?

As already said you can't use pin1 both for a servo and for Serial prints.

And that picture is useless. 6 bits of wire connected to nothing and one of them has another unidentified bit of wire plugged into it. But if by any chance you mean that you have 5 servos all powered from the Arduino 5V pin then don't. Servos need to be powered direct from a battery/power supply not from the Arduino.

Steve

My only concern with the wiring is the way the connections to the GND and 5V

maybe the problem is the current needed for servos. Because arduino didnt have much current to supply the motors.

nielyay

I got my Arduinos UNO R3 from this seller on Amazon (https://www.amazon.es/dp/B07BGWS1N7/ref=pe_3310721_189395781_TE_SCE_dp_1), I've rearranged the servo pin, but still keeps spinning only clockwise, now about the voltage, it's a parallel circuit, so shouldn't it be 5V across every servo, I've checked their requirements and they are supposed to work with voltages in between 4.8V and 7V

You must have a separate power supply for the servos, capable of several Amperes at 5-6V.

Connect all the grounds together.