 
 // 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(float user_speed)
+void step(float input_delay)
 {
   // The NXT/STEP minimum high pulse width is 2 microseconds.
   digitalWrite(amisStepPin, HIGH);


void loop()
{
  if(Serial.available()){
      String data = Serial.readString();
      
      // convert speed from RPM to milliseconds per step
      // 1 RPM = 200/60 steps/sec
      input_speed = data.substring(1,5).toInt();
      input_step = data.substring(6,14).toInt();
      input_mode = data.substring(15,18).toInt();
      input_delay = data.substring(19,25).toInt();
      if(data.substring(26) == "Up")
        setDirection(0);
      if(data.substring(26) == "Down")
        setDirection(1);
  
      // valid step modes: 1, 2, 4, 8, 16, 32, 64, 128
      stepper.setStepMode(input_mode);

      for (int x = 0; x < input_step; x++)
      {
        step(input_speed);
        Serial.println(x);
      }
  }

float input_step;
int input_mode;
float input_torque;
float input_delay;

AMIS30543 stepper;

