Has anyone had any experience using the Easy Driver with a stepper motor?
For my project I need the driver to disable when the stepper is not doing anything so the chip doesn't get hot but I can't seem to get it to run when I put disable commands in my code. Am I missing something obvious?
I'm using the enable pin on the driver to shut off power to the motor (i'm calling it DISABLE in the code because the pin has to be held HIGH to disable it) but when I press one of my button inputs it jerks a little bit then stops immediately.
#include <AccelStepper.h>
#define CLOSE_PIN 4
#define OPEN_PIN 2
#define DISABLE 7
// Define a stepper and the pins it will use
AccelStepper stepper(1, 9, 8);
int pos = 0;
void setup()
{
stepper.setMaxSpeed(6000);
stepper.setAcceleration(5000);
pinMode(CLOSE_PIN, INPUT_PULLUP);
pinMode(OPEN_PIN, INPUT_PULLUP);
pinMode(DISABLE, OUTPUT);
}
void loop()
{
digitalWrite(DISABLE, HIGH);
if (digitalRead(CLOSE_PIN) == 0) {
if (pos == 0) {
pos = 5000;
digitalWrite(DISABLE, LOW);
stepper.moveTo(pos);
}
}
else if (digitalRead(OPEN_PIN) == 0) {
if (pos == 5000) {
pos = 0;
digitalWrite(DISABLE, LOW);
stepper.moveTo(pos);
}
}
stepper.run();
}
Thanks in advance,
Nick