Skip to content

Commit a6e3b3c

Browse files
committed
Prevent division by zero in method setSpeed
Prevent division by zero in method setSpeed
1 parent 9f55a75 commit a6e3b3c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/Stepper/src/Stepper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
139139
*/
140140
void Stepper::setSpeed(long whatSpeed)
141141
{
142-
this->step_delay = 60L * 1000L * 1000L / this->number_of_steps / whatSpeed;
142+
this->step_delay = (whatSpeed) ? 60L * 1000L * 1000L / this->number_of_steps / whatSpeed : 0;
143143
}
144144

145145
/*

0 commit comments

Comments
 (0)