Hi everyone, I would like to comment on a rather peculiar situation, I am varying the RPM of a stepper motor nema 17 with driver a4988 in a cnc shield, and I am varying the rpm through an application in app inventor using bluetooth, with the application I vary well all speeds except when I put 50 rpm, the motor does not move, and it is strange because when I use the code without the use of bluetooth if I set rpm = 50; the motor does moves at that speed, at this point I would like ideas regarding this problem
#include <SoftwareSerial.h>
#include <AccelStepper.h>
// Definimos los pines utilizados
const int pinStep = 4;
const int pinDir = 7;
const int pinEnable = 8;
// Creamos un objeto de tipo AccelStepper
AccelStepper stepper = AccelStepper(1, pinStep, pinDir);
SoftwareSerial BTSerial(10, 11); // Creamos un objeto SoftwareSerial para la comunicación Bluetooth
int rpm = 0;
const int dir = -1; // 1 para CW, -1 para CCW
void setup() {
// Configuramos los pines
pinMode(pinEnable, OUTPUT);
digitalWrite(pinEnable, LOW); // Habilitamos el driver
// Configuramos el objeto AccelStepper
stepper.setMaxSpeed(2000); // Velocidad máxima en RPM
BTSerial.begin(38400); // Iniciamos la comunicación Bluetooth
}
void loop() {
char c;
if(BTSerial.available()) {
c = BTSerial.read();
if (c == '1') {
rpm = 50;
}
if (c == '2') {
rpm = 150;
}
if (c == '3') {
rpm = 250;
}
if (c == '4') {
rpm = 350;
}
if (c == '5') {
rpm = 450;
}
if (c == '6') {
rpm = 550;
}
if (c == '7') {
rpm = 0;
}
stepper.setSpeed((dir * rpm / 60) * 200);
}
stepper.runSpeed();
}
thank you