When I try control a servo and a stepper, things go awry. Why?

So basically what I am doing is, I am trying to make a robotic arm, but I don’t have enough motor right now, so for now I made a resembles of it to past time.

Parts I use:
Arduino Nano
4 channel RC RF (315MHz)
1K Potentiometer
Servo Motor (hd 1800a)
Stepper Motor (28byj-48)

How it works: I control servo with pot and arduino with rc rf.

Problem: If I control these motors individually, they work perfectly. But when I try to control them both, servo goes crazy. When I turn the pot all the way down It moves like a maniac, when up, servo does not go all the way, stucks somewhere around 170 degree.

Things I tried: I thought it was because of the power need of the system (which is around 1.5A, although I did not calculate it, it is still a generous estimation), so I tried to power with external power (5V-2.0A),
nothing changed. Tried to power servo alone, and it did not pick up from the pot, which is weird.

Code I use:

#include <Stepper.h>
#include <Servo.h>
double TEPS_PER_MOTOR_REVOLUTION=32;
double TEPS_PER_OUTPUT_REVOLUTION=32 * 64;
Stepper small_stepper(TEPS_PER_MOTOR_REVOLUTION, 3, 5, 4, 6);
Servo myservo;
int  Steps2Take;
unsigned long second,second2;
double save=0, save2=0;
int val;


void setup() {
  Steps2Take  =   -TEPS_PER_OUTPUT_REVOLUTION;  
  small_stepper.setSpeed(500);  
  Serial.begin(9600);
  myservo.attach(9);

}

void loop() {
  second = millis();  //Time passing
  second2= millis();
  if(digitalRead(8)==HIGH)
  {
    if (second-save>15){
    small_stepper.step(Steps2Take/512);
    save = second;
    }
  }
  
  else if(digitalRead(7)==HIGH)
  {
    if (second-save>15){
    small_stepper.step(-Steps2Take/512);
    save = second;
    } 
  }
  else {};
  val = analogRead(A0);
  val = map(val, 0, 1023, 0, 180);
  if (second2-save2>1)
  {
    myservo.write(val);
    save2 = second2;
  }

  

  

}

So, is there anyone who knows what is going on, and how to solve it.

which is around 1.5A, although I did not calculate it, it is still a generous estimation

For a system with a stepper and a servo, 1.5A is NOT a generous estimate of the current needed. It might even be too low.

double TEPS_PER_MOTOR_REVOLUTION=32;

Are you using a double so you can have 3.14 steps per revolution? Stepper motors do not have non-integral steps per revolution.

  if(digitalRead(8)==HIGH)

Magic numbers suck. What is connected to pin 8? How, EXACTLY, is whatever it is wired?

Why do you have Serial.begin() in setup() with no Serial.print()s in loop()? Debugging by guesswork is the hardest way possible.

PaulS:
For a system with a stepper and a servo, 1.5A is NOT a generous estimate of the current needed. It might even be too low.

double TEPS_PER_MOTOR_REVOLUTION=32;

Are you using a double so you can have 3.14 steps per revolution? Stepper motors do not have non-integral steps per revolution.

  if(digitalRead(8)==HIGH)

Magic numbers suck. What is connected to pin 8? How, EXACTLY, is whatever it is wired?

Why do you have Serial.begin() in setup() with no Serial.print()s in loop()? Debugging by guesswork is the hardest way possible.

Servo uses around 460mA, as far as I can learn this stepper uses 70mA but let's say its 500mA too, so it is around 1A, let's say other use also 500mA (arduino etc)... I don't know let's say total useage is 2A. At least barely enough.

No, I am using integer numbers for the stepper. Don't look at the numbers, it is a very cheap and weird motor, but it works.

At pin 8 and 7, rf receiver is connected. When you push a button on rc, it makes the reciever send a signal through these pins.

I used the serial.begins to check if code was working. Long to explain

Your variables save and save2 should be unsigned long as they are used with millis()

It is pointless having second and second2 because they will both have the same value. And IMHO currentMillis or millisThisLoop would be a more meaningful name.

You need to give meaningful names to the pins (rather than using the pin numbers) to make it possible to make sense of your program.

It would also be useful if you provide a description of how your program is intended to work.

...R
Stepper Motor Basics
Several Things at a Time - using millis() for timing

Robin2:
Your variables save and save2 should be unsigned long as they are used with millis()

It is pointless having second and second2 because they will both have the same value. And IMHO currentMillis or millisThisLoop would be a more meaningful name.

You need to give meaningful names to the pins (rather than using the pin numbers) to make it possible to make sense of your program.

It would also be useful if you provide a description of how your program is intended to work.

...R
Stepper Motor Basics
Several Things at a Time - using millis() for timing

I mean it is rather a simple program. All I did, I did it for precaution. Cause of using millis in this program is to use the motors simultaneously. Other than that, program reads the voltage output from pot and uses this data to give a degree value to input into the servo. And when pins 7 and 8 high, arduino turns the stepper. Other than that nothing much is there.

compnaion:
. Other than that nothing much is there.

It may be clear to you but it is not clear to me. Of course you are under no obligation to make it clear for me.

...R

Servo uses around 460mA

Always budget at least 1 Ampere per servo, to account for the startup (stall) current.

jremington:
Always budget at least 1 Ampere per servo, to account for the startup (stall) current.

Tried to connect stepper to another arduino to power, then it works. How people menage to power multiple motors?

compnaion:
Tried to connect stepper to another arduino to power, then it works. How people menage to power multiple motors?

With an appropriate power supply. And good wiring from the supply to the motor controllers with a strong ground connection to the Arduino.

MorganS:
With an appropriate power supply. And good wiring from the supply to the motor controllers with a strong ground connection to the Arduino.

makes sense