[SOLVED]Easy Driver Help

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

On some passes through loop(), you enable the motor, and define a new position for it to go to. Then, you cause it to take one step, if it is time to step. On most passes, you disable the stepper, and tell it to run anyway. Doesn't seem reasonable to me. How do you expect that to work?

Oh, wait, it doesn't.

You should not disable the stepper unless it is at the last commanded position.

I've solved it. this works perfectly if anyone is interested:

#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;
int closeDistance = 5000;

void setup()
{  
stepper.setMaxSpeed(6000);
stepper.setAcceleration(5000);
pinMode(CLOSE_PIN, INPUT_PULLUP);
pinMode(OPEN_PIN, INPUT_PULLUP);
pinMode(DISABLE, OUTPUT);
}

void loop()
{

if (digitalRead(CLOSE_PIN) == 0) {
  if (pos == 0) {
    pos = closeDistance;
    digitalWrite(DISABLE, LOW);
    stepper.moveTo(pos);
  }
}
else if (digitalRead(OPEN_PIN) == 0) {    
  if (pos == closeDistance) {
    pos = 0;
    digitalWrite(DISABLE, LOW);
    stepper.moveTo(pos); 
  }
}
if (stepper.distanceToGo() == 0)
{
digitalWrite(DISABLE, HIGH);
}
stepper.run();
}