nrf24l01 + old aritronics + L298N need a little help.

I have had a go at reorganising the working code in Reply #26 into a series of short functions to separate the activities. If you do that it makes the code much more portable. To use the revised code in your wireless program you would just need to change the function getInputs()

(I have not tested this so there may be some silly typos)

void loop() {
    getInputs();
    calculateMotorValues();
    calculateServoPosition();
    driveMotors();
    updateServo();
}


//============

void getInputs() {
    x_pos = analogRead (x_key) ;  //Reading the horizontal movement value
    y_pos = analogRead (y_key) ;  //Reading the vertical movement value
    pot_value = analogRead (pot_pin);
}

//===========

void calculateMotorValues() {
    motorSpeed = 0;
    if (x_pos < 400){     //Rotating the left motor in clockwise direction
        motor_speed = map(x_pos, 400, 0, 0, 255);
        motorDir = 'F';
    }
    else if (x_pos > 600){    //Rotating the left motor in anticlockwise direction
        motor_speed = map(x_pos, 600, 1023, 0, 255);
        motorDir = 'R';
    }
    
    motorSpeed1 = 0;
    if (y_pos < 400){     //Rotating the left motor in clockwise direction
        motor_speedy = map(y_pos, 400, 0, 0, 255);
        motorDir1 = 'F';
    }
    else if (y_pos > 600){    //Rotating the left motor in anticlockwise direction
        motor_speed1 = map(y_pos, 600, 1023, 0, 255);
        motorDir1 = 'R';
    }
}

//=============

void calculateServoPosition() {
    servo_pos = map(pot_value, 0, 1024, 0,255); 
}

//=============

void driveMotors() {
    if (motorDir == 'F') {
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, HIGH);
    }
    else {
        digitalWrite(IN1, HIGH;
        digitalWrite(IN2, LOW);
    }
    analogWrite(EN_A, motor_speed);
    
    if (motorDir1 == 'F') {
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, HIGH);
    }
    else {
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);
    }
    analogWrite(EN_B, motor_speed);
    
}

//==============

void updateServo() {
    myServo.write(servo_pos); 
}

...R

PS ... If you are going to use this version be sure to get it working in the wired version first.