The if (digitalRead(Limit_1) == LOW) is being ignored.
I am not seeing any Serial.print() ouput.
My stepper motor is running.
digitalWrite(ENA, LOW); "should" stop the motor.
// motor runs
// Include the AccelStepper Library
#include <AccelStepper.h>
const int dirPin = 6;
const int stepPin = 7;
const int ENA = 4;
//int Limit_1 = 11;
int Limit_1 = A5;
//int ENA = 4;
AccelStepper myStepper(AccelStepper::DRIVER, stepPin, dirPin); // works for a4988 (Bipolar, constant current, step/direction driver)
void setup()
{
Serial.begin(115200);
myStepper.setMaxSpeed(5000); // this limits the value of setSpeed(). Raise it if you like. 15000 does not work
myStepper.setSpeed(1000); // [12495 works with METRO 12500 does not work]
pinMode(Limit_1,INPUT_PULLUP);
//pinMode(ENA, OUTPUT); // sets the digital pin 4 as output
//digitalWrite(ENA, HIGH);
//digitalWrite(Limit_1, HIGH);
}
void loop()
{
if (digitalRead(Limit_1) == LOW)
//if (digitalRead(Limit_1) == HIGH)
{
digitalWrite(ENA, LOW);
//ENA = LOW;
//ENA = HIGH;
Serial.print(digitalRead(Limit_1));
Serial.print("++++");
//Serial.println(ENA);
Serial.println(digitalRead(ENA));
}
myStepper.runSpeed(); // This will run the motor forever.
}
Hello
Post your sketch, well formated, with comments and in so called code tags "</>" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.
The code is posted in my first post.
But here ya go again.
// motor runs
// Include the AccelStepper Library
#include <AccelStepper.h>
const int dirPin = 6;
const int stepPin = 7;
const int ENA = 4;
//int Limit_1 = 11;
int Limit_1 = A5;
//int ENA = 4;
AccelStepper myStepper(AccelStepper::DRIVER, stepPin, dirPin); // works for a4988 (Bipolar, constant current, step/direction driver)
void setup()
{
Serial.begin(115200);
myStepper.setMaxSpeed(5000); // this limits the value of setSpeed(). Raise it if you like. 15000 does not work
myStepper.setSpeed(1000); // [12495 works with METRO 12500 does not work]
pinMode(Limit_1,INPUT_PULLUP);
pinMode(ENA, OUTPUT); // sets the digital pin 4 as output
//digitalWrite(ENA, HIGH);
//digitalWrite(Limit_1, HIGH);
}
void loop()
{
if (digitalRead(Limit_1) == LOW) //being ignored button press makes no difference. No Serial.print() output.
//if (digitalRead(Limit_1) == HIGH)
{
digitalWrite(ENA, LOW);
//ENA = LOW;
//ENA = HIGH;
Serial.print(digitalRead(Limit_1)); //Nothing
Serial.print("++++");
//Serial.println(ENA);
Serial.println(digitalRead(ENA));
}
myStepper.runSpeed(); // This will run the motor forever.
}