Pages: [1]   Go Down
Author Topic: motor shield help  (Read 2615 times)
0 Members and 1 Guest are viewing this topic.
mid west ND.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
sprocive@gmail.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

thanks in advance.


Logged

Sprocive

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
a seeed studio motor shield
A link would be handy,

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

mid west ND.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
sprocive@gmail.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}

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

Sprocive

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  // step one step:
  myStepper.step(10);
If you are not going to keep the comments up to date, why leave them in?

Code:
  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.
Logged

mid west ND.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
sprocive@gmail.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help i know what i half to do now.
Logged

Sprocive

mid west ND.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
sprocive@gmail.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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;


}


Logged

Sprocive

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
just wondering if i am heading in the right direction.
No. The pinMode() function takes exactly two arguments. Look them up.
Logged

Pages: [1]   Go Up
Jump to: