Long debounceDelay = 50 // the debounce time in ms increase if the output flickers Long lastStepDownDebounceTime = 0 // the last time the output pin was toggled Long lastStepUpDebounceTime = 0 // the last time the output pin was toggled So 160 mircosteps should make the motor spin 360 degrees once. 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.3 x 510 Ohm current limiting resistors for the LEDs.3 x LED for indicators, preferably different color.6- and 8-lead unipolar stepper can also be converted to bipolar by connecting the proper ends of the windings together and floating the center point – not a very difficult task but outside of the scope of this post Please check with the author, Brian Schmalz on the best source of them.
I used Nano and I had to move the outputs away from the D0 and D1 because it was messing with uploads (I think it’s only a problem with Nano specifically) but any Arduino will do – there are only 8 digital I/Os and one analog.Ĭircuit diagram for the EasyDriver + Arduino manual stepper controlThe parts list for the project is very short: The Arduino can be any incarnation thereof. The circuit is extremely simple because most of the hard work of commutating the windings of the stepper is done by the Allegro A3967 motor controller chip, mounted on the EasyDriver board. I had another project in mind but was dragging my foot for a long time, and seeing that someone else can also use results of your work provides a great motivation, so thanks, Yellow!Īrduino sketch for the manual EasyDriver control of bipolar stepper motorsĪlso see the code in the post below. Shout outs to forum user Yellow who in this thread provided an inspiration for the code modification. So, I decided to modify an earlier Arduino sketch I wrote for testing the world’s smallest stepper motor to make it a bit more useful (and clean any bugs in the process). But every once in a while you have an application where you need to press a button and rotate some kind of a jig at a preset angle or move something a preset distance if it’s a stepper-driven linear stage.
Stepper motors are great for accurate positioning because they move in discrete steps – a feature that makes them very appropriate for CNC software control.