Controlling two stepper motors on the serial screen accrdng to the angle value

Hello all friends
I want to ensure the movement of two bipolar stepper motors at the entered angle value according to the x and y angle (such as coordinate values) entered from the serial monitor I have been trying for a long time. I tried AccelStepper libraries, but I cannot drive the engine I shared on the link as I want. I am waiting for your suggestions on this matter.

#include <AccelStepper.h>
AccelStepper stepX(1,2,3);
AccelStepper stepY(1,4,5);




long x_axis;
long y_axis;

int movef=1;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  Serial.println(" X, Y enter value of angle: ");
//
  stepX.setMaxSpeed(2000);
  stepX.setAcceleration(2000);

  stepY.setMaxSpeed(2000);
  stepY.setAcceleration(2000);

  
//  stepX.setMaxSpeed(1000);
//  stepX.setAcceleration(50);
//  
//  stepX.moveTo(200);

}

void loop() {
  // put your main code here, to run repeatedly:

while(Serial.available()>0){
    
    movef=0;
    

    x_axis=Serial.parseInt();
    Serial.print(x_axis);
    Serial.print(" x axis");

    y_axis=Serial.parseInt();
    Serial.print(y_axis);
    Serial.print(" y axis");

    stepX.moveTo(x_axis);
    stepY.moveTo(y_axis);

    
    delay(100);
    Serial.print("hareket başladı....");
     
    }
  if((stepX.distanceToGo() != 0) || (stepY.distanceToGo() != 0) ){
    
    stepX.run();
    stepY.run();
    }

  if((movef == 00) && (stepX.distanceToGo() == 0) && (stepY.distanceToGo() == 0)){
    
    Serial.print("Completed!");
    Serial.println("");
    Serial.println("Enter next point x,y");
    movef=1;
    
    }
    

}

I try to drive one step to see is that work or not and its properly work even if turning very slowly. But ı have control two step and as angle value.

ı aplly 12 dc v with 100uf 16v cap
I use drv8825; ı set it vref value
And the curcit established on ardunio uno

17HS19-1684D-PG51-E1000.pdf (161 KB)

You need to explain in much more detail what actually happens when you run the program and what you want it to do that is different.

You certainly should NOT have a delay() in a program that uses the AccelStepper.run() function.

This is unlikely to work

while(Serial.available()>0){

because you are only checking for 1 character being available but you are expecting to be able to read several. Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

I think this

  if((stepX.distanceToGo() != 0) || (stepY.distanceToGo() != 0) ){
    
    stepX.run();
    stepY.run();
    }

  if((movef == 00) && (stepX.distanceToGo() == 0) && (stepY.distanceToGo() == 0)){
    
    Serial.print("Completed!");
    Serial.println("");
    Serial.println("Enter next point x,y");
    movef=1;
    
    }

can be simplified to this

  if(stepX.distanceToGo() == 0 && stepY.distanceToGo() == 0){
    Serial.print("Completed!");
    Serial.println("");
    Serial.println("Enter next point x,y")
  }
   
  stepX.run();
  stepY.run();

...R

Robin thank you so much for your answer as quickly.

// Define pin connections & motor's steps per revolution
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;

void setup()
{
  // Declare pins as Outputs
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}
void loop()
{
  // Set motor direction clockwise
  
  
  // Spin motor slowly
  for(int x = 0; x < stepsPerRevolution; x++)
  {
    digitalWrite(dirPin, HIGH);
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);  

      }
  }

When I try the code below, I can see that the motor is constantly rotating at a slow speed. However, there is no movement in the above code. Could there be a special case with engine datasheet? Why isn't he ever moving?

In the meantime ı am reviewing the link you shared

kalix38:
When I try the code below,

[.....]

However, there is no movement in the above code.

You refer to two programs but you have only posted one of them.

...R

Robin,The second example of the code I shared is the code example that I tested if the engine was running.

But the main thing I want to do is to move the two stepper motors according to the x, y values entered (example of the code I published first) on serial monitor
When I run the code I shared for the first time, no movement is observed in the engine.

kalix38:
Robin,The second example of the code I shared is the code example that I tested if the engine was running.

My problem is that your Reply #2 has only one program so I don't know what you mean by the second example

But the main thing I want to do is to move the two stepper motors according to the x, y values entered (example of the code I published first) on serial monitor
When I run the code I shared for the first time, no movement is observed in the engine.

In Reply #1 I made a suggestion for a better way to receive the data. Have you tried it?

And have you removed the delay() from your program?

...R

Datasheet says motor has a 50+ to 1 gearbox, even at 2000 steps per second, that's only about 12 RPM.

Hello friends finally ı did what exactly ı want it:): thaky you so much friends one of you help to find true angle moving for my steps and one of you helps totally choose step which gonna move and select on serial monitor(Robin really thanks bro your simple code totaly helps my problem).

I am veryyy pleased