Pages: [1]   Go Down
Author Topic: Control Multiple Stepper Motors  (Read 669 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have successfully connected one stepper motor to my Arduino Uno board and am currently using the included stepper library template to work off of because of my limited Arduino programming experience. If I wanted to control another motor with just the Uno board (as I am currently doing, no shield) how would I adjust the program to control multiple motors?
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 108
Posts: 4025
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post the code that you have already
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#include <Stepper.h>

const int stepsPerRevolution = 350; 

Stepper myStepper(stepsPerRevolution, 6,7,8,9);
Stepper myStepper1(stepsPerRevolution, 2,3,4,5);

void setup() {
  myStepper.setSpeed(55);
  Serial.begin(9600);
}

void loop() {
   Serial.println("C");
  myStepper.step(stepsPerRevolution);
  delay(500);

//This is where i need to control my additional stepper
   Serial.println("C");
  myStepper1.step(stepsPerRevolution);
  delay(500);
 
  Serial.println("!C");
  myStepper.step(-stepsPerRevolution);
  delay(500);

//This is where i need to control my additional stepper   
Serial.println("!C");
  myStepper1.step(-stepsPerRevolution);
  delay(500); 
}
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 108
Posts: 4025
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You already have 2 stepper motors defined, myStepper and myStepper1
What do they do already ?
What do you want them to do ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The first one functions normally, the second one does not do any function at all, and does not even take the second it should to run through the cycle with the pauses. I have also tried using the 'stepsPerRevolution1' variable, but that results in an error, probably because it belongs to the stepper library.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12534
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The first one functions normally, the second one does not do any function at all, and does not even take the second it should to run through the cycle with the pauses. I have also tried using the 'stepsPerRevolution1' variable, but that results in an error, probably because it belongs to the stepper library.

You haven't set the speed for the second stepper.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 108
Posts: 4025
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not familiar with the Stepper library but in your code you have
Code:
  myStepper.setSpeed(55);
in setup() but no corresponding command for myStepper1
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

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

Are you trying to drive a stepper motor directly from the Arduino pins? If the stepper motor is more then about 1/4 inch in diameter, say goodbye to your Arduino.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino worked fine for hours directly controlling the stepper. I will try setting the speed on stepper1. Thanks.
Logged

Pages: [1]   Go Up
Jump to: