Is it possible for someone two physical objects and treat them as one unit within the code so that they both receive the same instructions? The items in question are two bipolar stepper motors (200 steps per revolution for both) which I'm trying to control with one potentiometer (the purpose of the potentiometer is to control the speed of the motors).
Is there a way for me to control the two motors under one potentiometer?
The other materials included are:
An Arduino Uno
An Adafruit motor shield (version 2.3)
If there's any additional information that is needed to answer this question, please feel to post a question and I'll get back to you as quickly as possible.
At any point in the code where you would send commands to a control pin on the motor shield to control a single stepper can you not simply send the same commands to a second pin to control the second stepper via the motor shield ?
The one problem I face with that is that I am not sure how to send that command and have the motors run simultaneously. If there is a way to do this, I'd be all for it, but I just wanted to see if making them one unit was an option, as it would save time in the building of the project.
Can you do as so many 3D printers do for their Z axis and have the two steppers treated as a single one in code and just wire them to be controlled together?
wildbill:
Can you do as so many 3D printers do for their Z axis and have the two steppers treated as a single one in code and just wire them to be controlled together?
You can drive two stepper motors with a single driver if you wire the two motors in series.
If that is not satisfactory you will need a driver for each motor. You can connect an Arduino step pin to the step-pins of two drivers. Likewise for the direction pin.
#include <Stepper.h>
const int stepsPerRevolution = 200;
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myMotor->setSpeed(7);
}
void loop() {
// put your main code here, to run repeatedly:
myMotor->(1000);
}