Treating two objects as one

Hello all.

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:

  1. An Arduino Uno
  2. 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.

Thank you.

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.

If you post the code that runs one motor for a period it would be easier to suggest changes to make two motors run for the same period.

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.

Motor shields are usually a poor choice for driving stepper motors. Have a look at these links
Stepper Motor Basics
Simple Stepper Code

...R

UKHeliBob:
If you post the code that runs one motor for a period it would be easier to suggest changes to make two motors run for the same period.

Okay, I'll go ahead and post that.

And thank you Robin2, I'll take a look at those links. Quick question: What does it mean to set them up in a/ with a "Z-axis"?

Thank you.

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

Yes it does on mine, I forgot to add the motor shield library onto that code, but yes, besides that, it compiles.

jmast2018:
Quick question: What does it mean to set them up in a/ with a "Z-axis"?

I've no idea. Where did that come from?

...R

Do the motors always run the same together in your project?