I'm working on a head-mounted device that requires the use of 6 stepper motors. I am attempting to simultaneously drive two motors in this manner, as shown in the diagram.
Arduino is powered from USB, and motors are powered from a 9V battery.In reality, the motors are connected to drivers, but they are not drawn in the diagram because the simulator does not include them.
When I drive only one motor at a time, everything functions properly, indicating that the components are each functioning correctly. But when I drive two motors in this way, they don't work.
So I would like to ask if there is an error in my program, or what is the correct way to drive two motors simultaneously?
Stepper: ULN2003 driver+ 28BYJ-48
Thanks for answer in advance.
#include <Stepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
Stepper myStepper_second(stepsPerRevolution, 2, 4, 3, 5);
void setup() {
// set the speed at 5 rpm:
myStepper.setSpeed(5);
myStepper_second.setSpeed(5);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(2000);
Serial.println("counterclockwise");
myStepper_second.step(-stepsPerRevolution);
delay(2000);
}
In my experience this is the easiest way to tidy up the code and add the code tags
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.