Go Down

Topic: Control Multiple Stepper Motors (Read 758 times) previous topic - next topic

nlusskin

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?

UKHeliBob

Please post the code that you have already
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nlusskin

Code: [Select]
#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); 
}

UKHeliBob

You already have 2 stepper motors defined, myStepper and myStepper1
What do they do already ?
What do you want them to do ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

nlusskin

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.

PeterH


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.
I only provide help via the forum - please do not contact me for private consultancy.

UKHeliBob

I am not familiar with the Stepper library but in your code you have
Code: [Select]
  myStepper.setSpeed(55);
in setup() but no corresponding command for myStepper1
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

PaulS

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.

nlusskin

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

Go Up