Complete noob here so be gentle.
I am trying to control a 24V NEMA23 stepper motor using an ArduinoMega 2560 (R3).
I am using an ST-M5045 driver.
When I use the default Arduino Stepper library, the motor runs fine.
I am using pin 31 for the steps and pin 30 for the direction.
My code looks like:
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
void setup() {
pinMode(30,OUTPUT);
pinMode(31,OUTPUT);
digitalWrite(30,LOW);
digitalWrite(31,LOW);
}
void loop() {
digitalWrite(31,HIGH);
digitalWrite(31,LOW);
}
Now, I want to operate the same motor using AccelStepper but can't get any response.
My code looks lie:
#include <AccelStepper.h>
AccelStepper stepper3(1, 31, 30);
void setup()
{
stepper3.setMaxSpeed(400.0);
stepper3.setAcceleration(100.0);
stepper3.moveTo(100000);
}
void loop()
{
stepper3.run();
}
Any idea on why this is not working?
I have tried several variations here with no luck.
Thanks in advance for any help.
Regards,
James