Hey,
I'm having some trouble with running some 28BYJ-48 stepper motors using the Accelstepper library. I can get the motors to run and go through most of the commands fine, I'm just having trouble with restarting a motor after I've stopped it. What I want to do is (hopefully clearly!) outlined in the code below.
void setup(){
//delibrately set very high so stepper motor will continue to turn
stepper1.move(100000);
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(500);
}
void loop(){
//take the reading from the hall effect
time_now = millis();
he_11 = digitalRead(HE_11);
//run the run() function in a while loop waiting for HE_11
while (he_11 == 1){
stepper1.run();
he_11 = digitalRead(HE_11);
}
//motor stops when HE_11 triggered
//run a pre written function to change the output of the stepper and pause
engageO();
delay(1000);
time_now = millis();
he_22 = digitalRead(HE_22);
//run the run() function in a while loop waiting for HE_22
while (he_22 == 1){
stepper1.run();
he_22 = digitalRead(HE_22);
}
//motor stops when HE_22 triggered
//go back to the original setting and repeat
engageI();
delay(1000);
}
}
The motor turns fine the first time after the board has been reset, however after it has stopped and trys to turn the second time, it only vibrates and gets very hot. As it turns fine the first time, I assume it must just be a coding error somewhere - probably to do with my use of functions from Accelstepper. Any help would be really appreaciated.
Luke