Can't stop stepper motor using quadstepper driver.

hello, I'm new to stepper motor and I'm using quad stepper driver by spark fun (https://www.sparkfun.com/products/10507). I can't somehow happen to stop the motor. I'm trying to stop by sending a stop signal to the enable pin 22 by setting it low. does that even happen? Can anyone help me with that issue. The motor is pulolu stepper https://www.pololu.com/product/2267 and I'm using arduino mega2560. The library used is sparkfunquadstep.h.
Thanks

#include <SparkFunQuadstep.h>
int i;
int Distance;
quadstep quadstep;

void setup() {
  
  
  //quadstep.motor_pins(1,A1,36,A8,A9,A10); //ch 1
  //quadstep.motor_pins(2,10,9,8,7,4);      //ch 2
  quadstep.motor_pins(3,22,23,24,25,26);  //ch 3
  //quadstep.motor_pins(4,27,28,29,30,31);  //ch 4
 
}


void loop() {
 

  quadstep.motor_go(3,1,-50,2);//step motor 3
  Distance = Distance+1;
  i==digitalRead(Distance);
  delay(500);
     if (i=1)
      {     
      digitalWrite(22,LOW); 
      }
     
 
  delay(500); 
}

I don't know anything about the quadstep library and I can't find any documentation on the Sparkfun links. If you have found it, please post the link.

Is the code you have posted one of the Sparkfun examples ?

I presume you could control one of the motors (for testing) with this Simple Stepper Program

...R
Stepper Motor Basics

Hi Robin, this is the example code,
Thanks

/*
  SparkFun Electronics 2011
  Aaron Weiss, aaron at sparkfun dot com
  Beer-ware License: You can do whatever you want with this sketch.
                     If we meet someday, you can buy me a beer.
                     
  QuadSetpper Example Sketch. For use with an Arduino Mega2560 and 
  a 1.8 degree bipolar stepper motor.

  You must connect the STP pin for each motor as shown below.
  For rest of the pins, you choose where they go. 

  Motor1 STP pin: mega pin 11
  Motor2 STP pin: meag pin 5
  Motor3 STP pin: meag pin 6
  Motor4 STP pin: mega pin 46
  
  Library Usage: 
  
  motor_pins(x,y,z,l,m,n)
  x: motor channel number
  y: enable pin assignment
  z: direction pin assignment
  l: MS1 pin assignment
  m: MS2 pin assignment
  n: MS3 pin assignment
  
  motor_go(x,y,z,l)
  x: motor channel number
  y: step size: 1, 2, 4, 8, or 16
  z: increments for given step size
     for full step: 1 increment = 1.8deg
     for half step: 1 increment = 0.9deg and so on
     negaitve numbers rotate in the opposite direction
  l: torque/speed (0-10), 0 is high speed/low torque/low current
                          10 is low speed/high torque/high current (2.0A max)
                      
  stall(x)
  x: motor channel number
*/

// include the motor library
#include <SparkFunQuadstep.h>

// create an instance of the class motor
quadstep quadstep;

void setup() {
  
  // assign the pin connections
  quadstep.motor_pins(1,A1,36,A8,A9,A10); //ch 1
  quadstep.motor_pins(2,10,9,8,7,4);      //ch 2
  quadstep.motor_pins(3,22,23,24,25,26);  //ch 3
  quadstep.motor_pins(4,27,28,29,30,31);  //ch 4
 
}

//1.8deg = 1step
void loop() {
  
  // step motor 4 for 200 increments CW
  quadstep.motor_go(1,1,-200,2);
  delay(500);
  // step motor 4 for 200 increments CCW
  quadstep.motor_go(1,1,200,2);
  delay(500);
 
  // holds the motor in one position with full torque/current
  //motor.stall(4);
  //delay(500); 
}

martin3498637:
Hi Robin, this is the example code,

Thanks. But you have missed the important part - does it work ?

...R

  Distance = Distance+1;
  i==digitalRead(Distance);

Why are you changing the pin number on every pass through loop()? What kind of name is Distance for a pin number?

Why are you testing that the value of the pin is equal to i? Most people would be ASSIGNING the value to i. Why are you discarding the result of that comparison?

     if (i=1)

Why are you now assigning 1 to i?

  quadstep.motor_go(3,1,-50,2);//step motor 3

Since you only ever tell the stepper to go, and you do that on every pass through loop(), how can you ever expect the motor to stop?

What is pin 22 doing? Does your arduino even have a pin 22 (mine only goes up to 13)?

I wrote by own steeper motor code. One of the things I did was put LEDs on the output pins so I could see what my sketch was attempting to make the motor do. One of the other things I did was read the motor's data sheet and understand how you were supposed to make it go.

HI guys, well I have decided not to use this instead use a stall operation to stop the motor for 5 seconds. it works fine now. the problem with the code was the i was using the wrong command for the stall.
the command is quad.stall(3) for motor 3 to stop