Instructables

Step 4: Test the motors

Picture of 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)
right_motor.setSpeed(200);
left_motor.setSpeed(200);
}

void loop() {
//step each motor every time through the loop
right_motor.step(10);
left_motor.step(10);
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.

 
Remove these adsRemove these ads by Signing Up