Error msg motor not declare

Hi
I need to use this code with arduino uno , cnc shield, motor nema 17 & drv8825 , but it gave error msg ( motorA was not declared in this scope ).

May anyone help me to solve this error please .

#include <AccelStepper.h>




void setup()
{
 

  motorA.setEnablePin(MOTOR_A_ENABLE_PIN);
  motorA.setPinsInverted(false, false, true);
  motorB.setEnablePin(MOTOR_B_ENABLE_PIN);
  motorB.setPinsInverted(false, false, true);

  motorA.setAcceleration(100);  
  motorA.move(1000);
  //motorA.setMaxSpeed(100);
  //motorA.setSpeed(100);

  motorB.setAcceleration(100);  
  motorB.move(1000);
  //motorB.setMaxSpeed(100);
  //motorB.setSpeed(100);

  motorA.enableOutputs();
  motorB.enableOutputs();
  
  pinMode(MOTOR_A_ENABLE_PIN, OUTPUT);
pinMode(MOTOR_B_ENABLE_PIN, OUTPUT);
}

void loop()
{

  motorA.run();
   motorB.run();

}

Hi,
Have you had a look at the example codes that come with the AccelStepper library;
Below is an example, and you need a lot more code before void setup() to make it work.

// AFMotor_ConstantSpeed.pde
// -*- mode: C++ -*-
//
// Shows how to run AccelStepper in the simplest,
// fixed speed mode with no accelerations
// Requires the AFMotor library
// (https://github.com/adafruit/Adafruit-Motor-Shield-library)
// Caution, does not work with Adafruit Motor Shield V2
// See https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library 
// for examples that work with Adafruit Motor Shield V2.


#include <AccelStepper.h>
#include <AFMotor.h>


AF_Stepper motor1(200, 1);




// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
void forwardstep() {  
  motor1.onestep(FORWARD, SINGLE);
}
void backwardstep() {  
  motor1.onestep(BACKWARD, SINGLE);
}


AccelStepper stepper(forwardstep, backwardstep); // use functions to step


void setup()
{  
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");
  
   stepper.setMaxSpeed(50);	
   stepper.setSpeed(50);	
}


void loop()
{  
   stepper.runSpeed();
}

Tom… :slight_smile:

motorA was not declared in this scope

The compiler is not telling lies. motorA does not appear to be declared anywhere in the program. Neither does motorB for that matter