class MKSStepperMotors {
public:
int _dirPin;
int _stepPin;
int _enablePin;
MKSStepperMotors(int dirPin, int stepPin, int enablePin) {
int _dirPin = dirPin;
int _stepPin = stepPin;
int _enablePin = enablePin;
//Habilitamos el motor
pinMode(_enablePin, OUTPUT);
digitalWrite(_enablePin, LOW);
//Cambiamos la direccion y aumentamos la velocidad
pinMode(_dirPin, OUTPUT);
digitalWrite(_dirPin, LOW);
// Le indicamos el pin de señal
pinMode(_stepPin, OUTPUT);
}
void move(int steps, int stepDelay)
{
for (int x = 0; x < steps; x++) {
Serial.println(_stepPin); // <-- _stepPin is zero and not 26 as it should
digitalWrite(_stepPin, HIGH); <-- _stepPin is zero and not 26 as it should
delayMicroseconds(stepDelay);
digitalWrite(_stepPin, LOW); <-- _stepPin is zero and not 26 as it should
delayMicroseconds(stepDelay);
}
}
};
MKSStepperMotors pedo(28, 26, 24);
void setup() {
Serial.begin(250000);
}
void loop() {
pedo.move(3200,100);
}
class MKSStepperMotors {
public:
int _dirPin;
int _stepPin;
int _enablePin;
MKSStepperMotors(int dirPin, int stepPin, int enablePin) {
int _dirPin = dirPin;
int _stepPin = stepPin;
int _enablePin = enablePin;
//Habilitamos el motor
pinMode(_enablePin, OUTPUT);
digitalWrite(_enablePin, LOW);
//Cambiamos la direccion y aumentamos la velocidad
pinMode(_dirPin, OUTPUT);
digitalWrite(_dirPin, LOW);
// Le indicamos el pin de señal
pinMode(_stepPin, OUTPUT);
}
void move(int steps, int stepDelay)
{
for (int x = 0; x < steps; x++) {
Serial.println(_stepPin); // <-- _stepPin is zero and not 26 as it should
digitalWrite(_stepPin, HIGH); <-- _stepPin is zero and not 26 as it should
delayMicroseconds(stepDelay);
digitalWrite(_stepPin, LOW); <-- _stepPin is zero and not 26 as it should
delayMicroseconds(stepDelay);
}
}
};
MKSStepperMotors pedo(28, 26, 24);
void setup() {
Serial.begin(250000);
}
void loop() {
pedo.move(3200,100);
}