Go Down

### Topic: motor shield help (Read 4217 times)previous topic - next topic

#### sprocive

##### Oct 06, 2012, 02:23 am
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.

Sprocive

#### PaulS

#1
##### Oct 06, 2012, 04:10 am
Quote
a seeed studio motor shield

Quote
i am using this stepper example

But, you don't have a stepper, do you?

Quote
the pins i am using 8,9,10,11.

For what>

Quote
how do i find the pins i need.

Look at the datasheet for the shield. I'm sure that the information is there.

#### sprocive

#2
##### Oct 06, 2012, 11:08 pm
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?
/*
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);
}

void loop() {
// step one step:
myStepper.step(10);
Serial.print("steps:" );
Serial.println(stepCount);
stepCount++;
delay(500);
}
Sprocive

#### PaulS

#3
##### Oct 07, 2012, 03:02 pm
Code: [Select]
`  // step one step:  myStepper.step(10);`
If you are not going to keep the comments up to date, why leave them in?

Code: [Select]
`  Serial.print("steps:" );  Serial.println(stepCount);  stepCount++;`
This doesn't match what you have actually stepped.

Quote
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.

#### sprocive

#4
##### Oct 07, 2012, 03:21 pm
thanks for the help i know what i half to do now.
Sprocive

#### sprocive

#5
##### Oct 15, 2012, 07:38 pm
this is what i have done for my script right now. just wondering if i am heading in the right direction.

thanks for the help in advance.

void setup() {
// put your setup code here, to run once:
pinMode(8,9,10,11);
pinMode(4,5,6,7);

speed = 30rpm;

}

Sprocive

#### PaulS

#6
##### Oct 15, 2012, 08:41 pm
Quote
just wondering if i am heading in the right direction.

No. The pinMode() function takes exactly two arguments. Look them up.

Go Up

Please enter a valid email to subscribe