#include <Arduino.h>
#include "BasicStepperDriver.h"
#define MOTOR_STEPS 200
#define MICROSTEPS 1
#define STEP 13
#define DIR 12
#define RPM 160
BasicStepperDriver Stepper(MOTOR_STEPS, STEP, DIR);

#define TRIG 4
#define ECHO 3
int distancia;

void setup(){
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
Stepper.begin(RPM, MICROSTEPS);
Serial.begin(9600);
}

void loop(){
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG, LOW);
distancia = pulseIn(ECHO, HIGH)  / 58;
Serial.print("distancia: ");
Serial.println(distancia);
delay(500);
while(distancia >= 20){
  Stepper.move(MOTOR_STEPS*5);
  break;
}
}
A4988