Step 4: Test the motors

Create two EasyDriver/breadboard/motor assemblies.  Plug the stepper motor header into the breadboard in line with the motor pins on the EasyDriver. The red and green wires should be next to A on theEasyDriver, and the blue and yellow wires next to B.  Use a benchtop power supply to get 12V power and ground to the GND and M+ pins on each of the EasyDrivers. Set them up to interface with the Arduino as follows:

For the left motor:
• Arduino GND to GND on left EasyDriver
• Arduino pin 11 goes to DIR
• Arduino pin 12 goes to STEP

For the right motor:
• Arduino GND (one of the two GND pins left) to GND on right EasyDriver
• Arduino pin 6 goes to DIR
• Arduino pin 7 goes to STEP

Make sure the two stepper motors work. Type in the following code, verify it,
and upload it to the Arduino.

Driving two stepper motors with an Arduino through
Sparkfun's EasyDriver v4.3
By Ben Leduc-Mills and Dustyn Roberts
Created: 2010.06
#include Stepper.h  //import stepper library

#define STEPS 200 // 360/1.8 (step angle) = 200 steps/revolution
//declare new stepper objects from stepper library (one per motor)
Stepper right_motor(STEPS, 6, 7); //6=DIR, 7=STEP
Stepper left_motor(STEPS, 11, 12); //11=DIR, 12=STEP

void setup() {
//set motor speeds (in RPM)

void loop() {
//step each motor every time through the loop
delay(10); //gives the motor a chance to get to new step

If the code works, your motors should just start spinning slowly. Attach some tape
flags to the motor shafts as shown to help indicate what’s going on.

I have a question about the direction functions. You have given a non-integer value for the .step() and the arduino standard requires an integer.<br>i.e.<br>void downLeft(int distance)<br>{<br>for( i = 0; i &lt; distance; i++) {<br>right_motor.step(-2);<br>left_motor.step(.2);//non-integer value given here<br>}<br>}<br><br>Is this an undocumented feature of the .step() function?<br>
Nice catch - I think that may be a typo. I believe the . is a typo in both instances, not sure how that got in there.
Acutally, what I'm really wondering is that the upLeft, upRight, downLeft, downRight functions supposed to produce diagonal lines?<br><br>Thanks.
This is a brilliant how-to for making a drawbot like this, clear instructions. I really could have done with this a few months ago!
Thankssssss post a picture/link if you make one!
Solar panels =D Nice touch.
Good job!<br> <br> How about <a href="http://www.cgl.uwaterloo.ca/~csk/projects/tsp/">TSP art</a> to draw non-random pictures?<br>
That would be excellent! If you come up with a mod to the code you should post it!
The TSP calculation would be way too much resource hungry for an Arduino.<br> Cooperation with a PC seems necessary.<br> <br> The <a href="http://www.tsp.gatech.edu/concorde.html">Concorde solver</a> can produce coordinate files.<br>
Cool Bot! Great Ible! <br><br>Off topic;<br><br>How many people after reading the name immediately thought of Marvin the Robot when you saw this title?<br><br>Sad Robot...
haha I love a good hitchhiker's reference, thanks
I am not ready to try a project like this but it looks a great combination of electronic and art. Really nice work.

About This Instructable




Bio: I'm an enginerd, author, and teacher.
More by dustynrobots:Magic Flip Lantern The Standing Ovation Sensor Robotic Arm with Servo Motors 
Add instructable to: