Accel Stepper help, stepper not going backwards So my question is that I am trying to use a arduino library called Accel Stepper to control a stepper motor, I made code that makes the stepper motor move one rev clockwise and then one rev counter clockwise 

however as i run the code, the motor has no problem going clockwise, however when it comes to reversing the shaft of the motor stays still and doesn't move while the whole motor itself vibrates, what could be my problem? 

here is my code:  

    // MultiStepper.pde
    // -*- mode: C++ -*-
    //
    // Shows how to multiple simultaneous steppers
    // Runs one stepper forwards and backwards, accelerating and decelerating
    // at the limits. Runs other steppers at the same time
    //
    // Copyright (C) 2009 Mike McCauley
    // $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

    #include &lt;AccelStepper.h&gt;
    int user = 800;
    // Define some steppers and the pins the will use

    AccelStepper stepper2(AccelStepper::DRIVER, 9,8 );
    AccelStepper stepper3(AccelStepper::DRIVER, 4, 7);

    void setup()
    {  

        stepper2.setMaxSpeed(1000);  
        stepper2.setSpeed(300);  


    }

    void loop()
    {
        // Change direction at the limits
      stepper2.moveTo(user);
      stepper2.setSpeed(300);  
      stepper2.runSpeedToPosition();   
      if (stepper2.distanceToGo() == 0){ 
        stepper2.moveTo(-stepper2.currentPosition());  
        stepper2.setSpeed(300);  
        stepper2.runSpeedToPosition(); 
      } 


    }
Work through your code. When it gets to the target position, your loop looks like this:

void loop()
{
    // Change direction at the limits
  stepper2.moveTo(user);
  stepper2.setSpeed(300);  
  stepper2.runSpeedToPosition();   
    stepper2.moveTo(-stepper2.currentPosition());  
    stepper2.setSpeed(300);  
    stepper2.runSpeedToPosition(); 


}


So you say, move to position 'user', then move to position '-stepper2.currentPosition'. Then as the loop comes around you again say move to position 'user', and so on.

The loop will repeat hundreds if no thousands of times per second, so you are basically telling the stepper motor to change direction thousands of times per second which will be why the motor starts vibrating when it gets to the user position.

If, just for the sake of argument, you were to move the first three lines of code in the loop() function to the setup() function, what behaviour do you think you will observe?