- Suggestion for the next version of the Stepper library ---
I was testing the Stepper library with the 28BYJ-48 stepper motor and I noticed that the stepper motor still continued with the last coils triggered after the call function, warming them up and consuming power. So I added a function to disconnect the last used coils.
On Windows, the codes are in "C: \ Program Files \ arduino-nightly \ libraries \ Stepper \ src" and you need to change the security of the files.
In stepper.cpp:
- Added function below:
void Stepper::turnOff()
{
if (this->pin_count == 2) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
}
if (this->pin_count == 4) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
digitalWrite(motor_pin_3, LOW);
digitalWrite(motor_pin_4, LOW);
}
if (this->pin_count == 5) {
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
digitalWrite(motor_pin_3, LOW);
digitalWrite(motor_pin_4, LOW);
}
- I called the function turnOff () as the last command in "void function Stepper :: step (int steps_to_move)" - before the last "close parentheses"
void function Stepper :: step (int steps_to_move)
{
....
turnOff();
}
At Stepper.h:
- Added "void Stepper::turnOff();" in private clause;