#include <AccelStepper.h>
char dato='n';
int pasos=0, b1=0;
AccelStepper motor_1(1,12,14);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
motor_1.setSpeed(50); motor_1.setMaxSpeed(200); motor_1.setAcceleration(5);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
if(Serial.available()){
dato=Serial.read();
if(dato=='P'){
pasos=Serial.parseInt();
motor_1.moveTo(pasos);
b1=1;
}
}
motor_1.run();
if(motor_1.distanceToGo()==0 && b1==1){
b1=0;
dato='n';
}
}