i am trying to hook two motors to a seeed studio motor shield i am using this stepper example to start me out.
but the pins are set up for one motor i wood like to add two motors to it i am using arduino 2560 mega
the pins i am using 8,9,10,11. how do i find the pins i need.
this is what i am working with i got both motors to work. but i need them to work at the same time. how wood i do this?
thanks in advance
/*
Stepper Motor Control - one step at a time
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor will step one step at a time, very slowly. You can use this to
test that you've got the four wires of your stepper wired to the correct
pins. If wired correctly, all steps should be in the same direction.
Use this also to count the number of steps per revolution of your motor,
if you don't know it. Then plug that number into the oneRevolution
example to see if you got it right.
Created 30 Nov. 2009
by Tom Igoe
*/
#include <Stepper.h> #include <Stepper.a>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
Stepper mySteppera(stepsPerRevolution, 4,5,6,7);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// initialize the serial port:
Serial.begin(9600);
}
This doesn't match what you have actually stepped.
but i need them to work at the same time. how wood i do this?
You can't make two steppers step at the same time. Only one can step at a time.
If you are trying to build some kind of CNC machine, there are ways to microstep each motor so that the resulting motion of the pair approximates the motion you are trying to achieve. The actual motion will still involve stair-stepping, but that is true of any CNC machine. The key is to make the steps small enough.
There is nothing in your code that causes the other stepper (mySteppera is poor name) to ever move.