I'm trying to make a project that involves rotating a stepper motor 45 degrees with a button in the app, but it's not working for me and I don't understand how to fix it.
this is the code:
#include <AccelStepper.h>
#define motorInterfaceType 8
AccelStepper stepper(motorInterfaceType, 19, 18, 5, 17);
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_Stepper"); //
stepper.setMaxSpeed(1000);
stepper.setAcceleration(500);
}
void loop() {
if (SerialBT.available()) {
char cmd = SerialBT.read();
if(cmd == 'R') {
stepper.move(256); // 45°
while(stepper.distanceToGo() != 0) {
stepper.run();
}
}
}
}