   delay(300);
 
   // Step in the other direction 1000 times.
-  stepper.setDirection(1);
+  setDirection(1);
   for (unsigned int x = 0; x < 1000; x++)
   {
     step();


const uint8_t amisSlaveSelect = 4;
const uint8_t amisStepPin = 5;

AMIS30543 stepper;

void setup()
{
  SPI.begin();
  pinMode(amisStepPin, OUTPUT);
  delay(1);

  stepper.init(amisSlaveSelect);
  stepper.resetSettings();
  stepper.setCurrentMilliamps(245);
  stepper.setStepMode(32);
  stepper.enableDriver();
}

void loop()
{
  // Step in the default direction 1000 times.
  stepper.setDirection(0);
  for (unsigned int x = 0; x < 1000; x++)
  {
    step();

  delay(300);
}

// Sends a pulse on the NXT/STEP pin to tell the driver to take
// one step, and also delays to control the speed of the motor.
void step()
{
  // The NXT/STEP minimum high pulse width is 2 microseconds.
  digitalWrite(amisStepPin, HIGH);
  delayMicroseconds(3);
  digitalWrite(amisStepPin, LOW);
  delayMicroseconds(3);

  // The delay here controls the stepper motor's speed.  You can
  // increase the delay to make the stepper motor go slower.  If
  // you decrease the delay, the stepper motor will go fast, but
  // there is a limit to how fast it can go before it starts
  // missing steps.
  delayMicroseconds(2000);
}

// Writes a high or low value to the direction pin to specify
// what direction to turn the motor.
void setDirection(bool dir)
{
  // The NXT/STEP pin must not change for at least 0.5
  // microseconds before and after changing the DIR pin.
  delayMicroseconds(1);
  digitalWrite(amisDirPin, dir);
  delayMicroseconds(1);
}
