You are on page 1of 7

http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.

html
Example 1: Basic Arduino setup
This is the most basic example you can have with an Arduino, an Easy Driver, and a stepper
motor. Connect the motor's four wires to the Easy Driver (note the proper coil connections,
connect a power supply of !"# is to the $ower %n pins, and connect the Arduino's &'D, pin
( and pin ) to the Easy Driver.
Then load this s*etch and run it on your Arduino or chip+%T,
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
void loop() {
digitalWrite(9, H!H);
dela"(#);
digitalWrite(9, LOW);
dela"(#);
}
%t doesn't -et much simpler than that. .hat is the code doin-/ %t sets up pin ( and ) as
outputs. %t sets them both low to be-in with. Then in the main loop, it simply to--les pin )
hi-h and low, waitin- !ms between to--les. .e use pin ) as the 0TE$ control and pin ( as
the D%1ECT%2' control to the Easy Driver.
0ince we are not pullin- either 30! or 30" low on the Easy Driver low, the Easy Driver will
default to !4(th microstep mode. That means that each time the 5di-ital.rite(), 6%&675 call
is executed, the stepper motor will move !4(th of a full step. 0o if your motor is !.( de-rees
per step, there will be "88 full steps per revolution, or !988 microsteps per revolution.
0o how fast is this code -oin- to run the stepper/ .ell, with the 0TE$ si-nal !ms hi-h and
!ms low, each complete pulse will ta*e "ms of time. 0ince there are !888ms in ! second,
then !8884" : ;88 microsteps4second.
.hat if we wanted the motor to -o slower/ .e chan-e the delay(7 lines to have lon-er
delays. %f you use delay(!87 for both, the you'll move at ;8 microsteps4second.
.hat if you wanted the motor to -o faster/ .e can't really delay for less than ! ms, can we/
<es, of course we can= .e can chan-e the delay( calls to delay3icroseconds(!887 calls and
then each delay would be !88 microseconds (or us, so the motor would be driven at ;888
microsteps4second.
'ow, one thin- you should play with is the current ad>ustment pot on your Easy Driver. <ou
need a tiny little screw driver to turn it, and be sure not to force it too far one way or the other
(they're delicate. Also, some Easy Drivers were built with pots that have no physical stops
on them, so they spin around and around. As you run the above code, slowly turn the pot one
way or the other. Dependin- upon the type of motor you have (and its coil resistance you
may hear4feel no difference as you spin the pot, or you may notice ?uite a bi- difference.

You might also like