most small and micro steppers, especially those that came from a CD- or DVD-R/RW drives Int stepsPassedMax = 160 // trying to calculate steps per revolution (remember the microstepping settings 1/8th is default) RPMs)Ĭonst byte enablePin = 6 // turn EasyDriver off when not turning (saves power but ONLY use when there's no need to hold position)īyte ledState = LOW // the current state of the output pinīyte lastStepUpButtonState = HIGH // the previous reading from the step UP pinīyte lastStepDownButtonState = HIGH // the previous reading from the step DOWN pinīyte directionState=HIGH // the current directionīyte stepUpState=HIGH // the current state of UP buttonīyte stepDownState=HIGH // the current state of DOWN button
They're used here toĬonst byte stepUpPin = 4 // the number of the step pinĬonst byte stepDownPin = 5 // the number of the step pinĬonst byte ledPin = 12 // pin # for direction indicator LEDĬonst byte readyPin = 11 //pin # for LED that comes on when all the steps have been completedĬonst byte inMotionPin = 10 // pin # for the LED that light up when the stepper is supposed to be still movingĬonst byte ratePin = 0 // A0 - analog 0 pin on Arduino to control the stepping dealy (i.e. The smaller the stepDelay variable, the faster the motor turns.
If you have a better stepper (200SPR is common), it may only be 1/10th of one rotation – check with the datahseet on the motor and adjust the stepsPassedMax accordingly or send, say, 200*8= 1600 steps and see if the motor completes a full 360 degree revolution if you don’t have a datasheet and suspect that this is a 200SPR motor.Īnother adjustment you may make is the desired RPMs or, more appropriately, angular speed since you may not even need a full rotation, hence no R in RPM: It just happens that the micro stepper I was using earlier (not the one on the video) had 20 SPR (Steps Per Revolution) and this would have been one 360 degree rotation of the motor’s shaft. Note the int stepsPassedMax = 160 line (line 28).Here 160 means 20 full steps in 1/8th microstepping mode. 1 x 10K Ohm potentiometer (anything between 1K and 100K is fine)Ĭouple of lines in the Arduino code you may want to look at and adjust to your needs are highlighted in the code below.2 x 10K Ohm pullup resistors for the buttons.