@@ -88,6 +88,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
8888 this ->direction = 0 ; // motor direction
8989 this ->last_step_time = 0 ; // timestamp in us of the last step taken
9090 this ->number_of_steps = number_of_steps; // total number of steps for this motor
91+ this ->idle = false ; // Power down all coils after done stepping
9192
9293 // Arduino pins for the motor control connection:
9394 this ->motor_pin_1 = motor_pin_1;
@@ -118,6 +119,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
118119 this ->direction = 0 ; // motor direction
119120 this ->last_step_time = 0 ; // timestamp in us of the last step taken
120121 this ->number_of_steps = number_of_steps; // total number of steps for this motor
122+ this ->idle = false ; // Power down all coils after done stepping
121123
122124 // Arduino pins for the motor control connection:
123125 this ->motor_pin_1 = motor_pin_1;
@@ -150,6 +152,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
150152 this ->direction = 0 ; // motor direction
151153 this ->last_step_time = 0 ; // timestamp in us of the last step taken
152154 this ->number_of_steps = number_of_steps; // total number of steps for this motor
155+ this ->idle = false ; // Power down all coils after done stepping
153156
154157 // Arduino pins for the motor control connection:
155158 this ->motor_pin_1 = motor_pin_1;
@@ -226,6 +229,21 @@ void Stepper::step(int steps_to_move)
226229 yield ();
227230 }
228231 }
232+ // If ideling is enabled then power down all coils
233+ if (this ->idle == true )
234+ {
235+ digitalWrite (motor_pin_1, LOW);
236+ digitalWrite (motor_pin_2, LOW);
237+ if (this ->pin_count == 4 )
238+ {
239+ digitalWrite (motor_pin_1, LOW);
240+ digitalWrite (motor_pin_2, LOW);
241+ digitalWrite (motor_pin_3, LOW);
242+ digitalWrite (motor_pin_4, LOW);
243+ }
244+ if (this ->pin_count == 5 )
245+ digitalWrite (motor_pin_5, LOW);
246+ }
229247}
230248
231249/*
@@ -358,6 +376,15 @@ void Stepper::stepMotor(int thisStep)
358376 }
359377}
360378
379+ /*
380+ * Allow powering down all coils after stepping,
381+ * to reduce heat, power and allow manuall rotation.
382+ */
383+ void Stepper::idelAfterStep (bool idle)
384+ {
385+ this ->idle = idle;
386+ }
387+
361388/*
362389 version() returns the version of the library:
363390*/
0 commit comments