Hi all,
I am using a motor shield with the arduino Uno.
I want to be able to run 2 stepper motors simultaneously.
This is a code that runs the 2 motors, but not simultaneously, as in, for motor 2 to start, it has to wait for motor 1 to stop.
I have tried to use 'parfor' loops instead of 'for' loops, that didn't do the trick.
I have tried uploading an edited version of the srv.pde to integrate the I2C and AccelStepper libraries, but I'm not getting a simultaneous movement either...
I added to the srv.pde:
#include <Wire.h>
#include <AccelStepper.h>
and to the void loop (), I added:
Wire.beginTransmission (100);
and uploaded that as to the master arduino.
and uploaded to the slave arduino:
#include <Wire.h>
void setup()
{
Wire.begin(100);
Wire.onReceive(receiveEvent);
}
void loop()
{}
void receiveEvent( int howMany)
{
while (Wire.available())
{}}
I need help modifying the srv.pde so that when I upload it, I would be able to run the stepper motors simultaneously. Or another way, without having to modify the srv.pde file, to be able to run the motors simultaneously...
Thank you.
[Merged information from duplicate Question]
Hi, I have 2 arduinos, 2 motor shields, and 2 stepper motors. I want the 2 motors to run simultaneously, when I connect the 2 steppers to one arduino, the motors do not run at the same time. For example, in a for loop like this, motor 1 will run, stop, then moto 2 will run, stop.
for k=1:3;
a.stepperStep(1,'forward','double',200);
a.stepperStep(2,'forward','double',200);
end
The same issue occurs if I have 2 arduinos connected. For example, the for loop would be like this:
for k=1:3;
a.stepperStep(1,'forward','double',200);
b.stepperStep(1,'forward','double',200);
end
with "b." representing a different arduino than the "a."
Is there a way to make the 2 motors run at the same time?
Thank you.